diff options
author | Andrei Zeliankou <zelenkov@nginx.com> | 2023-05-10 13:02:52 +0100 |
---|---|---|
committer | Andrei Zeliankou <zelenkov@nginx.com> | 2023-05-10 13:02:52 +0100 |
commit | e88e16d11e8d197f27d292540a015cf05af6277f (patch) | |
tree | 158f93f7fc50ef72b85de44e879fef0e3c04d6fa /test/conftest.py | |
parent | dc0391441807c535e1f021263572128459a69d6a (diff) | |
download | unit-e88e16d11e8d197f27d292540a015cf05af6277f.tar.gz unit-e88e16d11e8d197f27d292540a015cf05af6277f.tar.bz2 |
Tests: added tests for NJS loadable modules.
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'] |