diff options
author | John Estabrook <jestabro@vyos.io> | 2023-11-25 20:00:31 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2023-12-01 09:43:53 -0600 |
commit | 4fcf4ce92b7c1de479070f5b392520984564ad16 (patch) | |
tree | a94e075ad946c487f58e56ef2966b23b97c22873 /smoketest/scripts/cli/test_service_https.py | |
parent | 006931b8f1926a239bb5be4e27eb40bbe071219c (diff) | |
download | vyos-1x-4fcf4ce92b7c1de479070f5b392520984564ad16.tar.gz vyos-1x-4fcf4ce92b7c1de479070f5b392520984564ad16.zip |
http-api: T5782: use single config-mode script for https and http-api
Diffstat (limited to 'smoketest/scripts/cli/test_service_https.py')
-rwxr-xr-x | smoketest/scripts/cli/test_service_https.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_service_https.py b/smoketest/scripts/cli/test_service_https.py index 24e1f1299..6cb91bcf1 100755 --- a/smoketest/scripts/cli/test_service_https.py +++ b/smoketest/scripts/cli/test_service_https.py @@ -254,6 +254,35 @@ class TestHTTPSService(VyOSUnitTestSHIM.TestCase): self.assertTrue(success) @ignore_warning(InsecureRequestWarning) + def test_api_add_delete(self): + address = '127.0.0.1' + key = 'VyOS-key' + url = f'https://{address}/retrieve' + payload = {'data': '{"op": "showConfig", "path": []}', 'key': f'{key}'} + headers = {} + + self.cli_set(base_path) + self.cli_commit() + + r = request('POST', url, verify=False, headers=headers, data=payload) + # api not configured; expect 503 + self.assertEqual(r.status_code, 503) + + self.cli_set(base_path + ['api', 'keys', 'id', 'key-01', 'key', key]) + self.cli_commit() + + r = request('POST', url, verify=False, headers=headers, data=payload) + # api configured; expect 200 + self.assertEqual(r.status_code, 200) + + self.cli_delete(base_path + ['api']) + self.cli_commit() + + r = request('POST', url, verify=False, headers=headers, data=payload) + # api deleted; expect 503 + self.assertEqual(r.status_code, 503) + + @ignore_warning(InsecureRequestWarning) def test_api_show(self): address = '127.0.0.1' key = 'VyOS-key' |