From 3fbb1c602bb5a5003f218e437b83401664e02227 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Sat, 25 Nov 2023 20:00:31 -0600 Subject: http-api: T5782: use single config-mode script for https and http-api --- smoketest/scripts/cli/test_service_https.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'smoketest/scripts') 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 @@ -253,6 +253,35 @@ class TestHTTPSService(VyOSUnitTestSHIM.TestCase): success = r.json()['data']['ShowVersion']['success'] 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' -- cgit v1.2.3