summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2021-02-15 03:11:26 +0000
committerAndrei Zeliankou <zelenkov@nginx.com>2021-02-15 03:11:26 +0000
commitcf530e19bc5cc0de67bd57a650a0adf3d58e0881 (patch)
tree98406b3c6d96b6582615d503652a9d7e05211957
parent11f7d833a9bad1fb3f066cee815fe9772bed4875 (diff)
downloadunit-cf530e19bc5cc0de67bd57a650a0adf3d58e0881.tar.gz
unit-cf530e19bc5cc0de67bd57a650a0adf3d58e0881.tar.bz2
Tests: clear certificates after each test.
-rw-r--r--test/conftest.py37
1 files changed, 29 insertions, 8 deletions
diff --git a/test/conftest.py b/test/conftest.py
index 35249a1f..b49fb377 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -185,7 +185,7 @@ def pytest_sessionstart(session):
check_isolation()
- assert 'success' in _clear_conf(unit['temp_dir'] + '/control.unit.sock')
+ _clear_conf(unit['temp_dir'] + '/control.unit.sock')
unit_stop()
@@ -281,11 +281,7 @@ def run(request):
# clean temp_dir before the next test
if not option.restart:
- conf_resp = _clear_conf(unit['temp_dir'] + '/control.unit.sock')
-
- if 'success' not in conf_resp:
- _print_log(log)
- assert 'success' in conf_resp
+ _clear_conf(unit['temp_dir'] + '/control.unit.sock', log)
open(unit['log'], 'w').close()
@@ -457,14 +453,39 @@ def _print_log(data=None):
sys.stdout.write(data)
-def _clear_conf(sock):
- return http.put(
+def _clear_conf(sock, log=None):
+ def check_success(resp):
+ if 'success' not in resp:
+ _print_log(log)
+ assert 'success' in resp
+
+ resp = http.put(
url='/config',
sock_type='unix',
addr=sock,
body=json.dumps({"listeners": {}, "applications": {}}),
)['body']
+ check_success(resp)
+
+ try:
+ certs = json.loads(http.get(
+ url='/certificates',
+ sock_type='unix',
+ addr=sock,
+ )['body']).keys()
+
+ except json.JSONDecodeError:
+ pytest.fail('Can\'t parse certificates list.')
+
+ for cert in certs:
+ resp = http.delete(
+ url='/certificates/' + cert,
+ sock_type='unix',
+ addr=sock,
+ )['body']
+
+ check_success(resp)
def run_process(target, *args):
global _processes