diff options
Diffstat (limited to 'test/conftest.py')
-rw-r--r-- | test/conftest.py | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/test/conftest.py b/test/conftest.py index 6d8e59fd..926d83f8 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -523,26 +523,31 @@ def _clear_conf(sock, *, log=None): assert 'success' in resp, 'clear conf' - if 'openssl' not in option.available['modules']: - return + def get(url): + return http.get(url=url, sock_type='unix', addr=sock)['body'] - try: - certs = json.loads( - http.get(url='/certificates', sock_type='unix', addr=sock)['body'] - ).keys() + def delete(url): + return http.delete(url=url, sock_type='unix', addr=sock)['body'] + + if 'openssl' in option.available['modules']: + try: + certs = json.loads(get('/certificates')).keys() + + except json.JSONDecodeError: + pytest.fail("Can't parse certificates list.") - except json.JSONDecodeError: - pytest.fail("Can't parse certificates list.") + for cert in certs: + assert 'success' in delete(f'/certificates/{cert}'), 'delete cert' - for cert in certs: - resp = http.delete( - url=f'/certificates/{cert}', - sock_type='unix', - addr=sock, - )['body'] + if 'njs' in option.available['modules']: + try: + scripts = json.loads(get('/js_modules')).keys() - assert 'success' in resp, 'remove certificate' + except json.JSONDecodeError: + pytest.fail("Can't parse njs modules list.") + for script in scripts: + assert 'success' in delete(f'/js_modules/{script}'), 'delete script' def _clear_temp_dir(): temp_dir = unit_instance['temp_dir'] |