From 6b1f99167bd28dbcad8f2c4bd564609c6e10ca97 Mon Sep 17 00:00:00 2001 From: Erik Olof Gunnar Andersson Date: Sat, 13 Aug 2022 18:43:30 -0700 Subject: Add basic test for disabling the api Change-Id: I0f6d3440e5b352770fe7da1808038c9b60ce8e23 --- designate/conf/api.py | 2 +- designate/tests/test_api/test_v2/__init__.py | 3 --- designate/tests/test_api/test_v2/test_api.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 designate/tests/test_api/test_v2/test_api.py diff --git a/designate/conf/api.py b/designate/conf/api.py index 87e6957d..29895e14 100644 --- a/designate/conf/api.py +++ b/designate/conf/api.py @@ -42,7 +42,7 @@ API_OPTS = [ help='The strategy to use for auth. Supports noauth or ' 'keystone'), cfg.BoolOpt('enable_api_v2', default=True, - help='enable-api-v2 which enable in a future'), + help='Enable the Designate V2 API'), cfg.BoolOpt('enable_api_admin', default=False, help='enable-api-admin'), cfg.IntOpt('max_header_line', default=16384, diff --git a/designate/tests/test_api/test_v2/__init__.py b/designate/tests/test_api/test_v2/__init__.py index 27337031..cd49c1b5 100644 --- a/designate/tests/test_api/test_v2/__init__.py +++ b/designate/tests/test_api/test_v2/__init__.py @@ -37,9 +37,6 @@ class ApiV2TestCase(ApiTestCase): def setUp(self): super(ApiV2TestCase, self).setUp() - # Ensure the v2 API is enabled - self.config(enable_api_v2=True, group='service:api') - # Create the application self.app = api_v2.factory({}) diff --git a/designate/tests/test_api/test_v2/test_api.py b/designate/tests/test_api/test_v2/test_api.py new file mode 100644 index 00000000..3d9bbddc --- /dev/null +++ b/designate/tests/test_api/test_v2/test_api.py @@ -0,0 +1,28 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from designate.tests.test_api.test_v2 import ApiV2TestCase + + +class ApiV2DisableTest(ApiV2TestCase): + def setUp(self): + self.config(enable_api_v2=False, group='service:api') + super(ApiV2DisableTest, self).setUp() + + def test_disable_v2_api(self): + urls = ['zones', 'pools', 'service_statuses'] + + for url in urls: + response = self.client.get('/%s/' % url, expect_errors=True) + + self.assertEqual(404, response.status_code) + self.assertEqual(b'', response.body) -- cgit v1.2.1