diff options
author | Zuul <zuul@review.opendev.org> | 2022-08-16 01:18:52 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2022-08-16 01:18:52 +0000 |
commit | 3c6b84154dcb7d21a58ad7136e2bb797fcd03f5d (patch) | |
tree | eb4417c0a242241020ac95055297fc4aa15d552b | |
parent | e68640d611a8868ce524f623f0583e4b58f01f8e (diff) | |
parent | 6b1f99167bd28dbcad8f2c4bd564609c6e10ca97 (diff) | |
download | designate-3c6b84154dcb7d21a58ad7136e2bb797fcd03f5d.tar.gz |
Merge "Add basic test for disabling the api"
-rw-r--r-- | designate/conf/api.py | 2 | ||||
-rw-r--r-- | designate/tests/test_api/test_v2/__init__.py | 3 | ||||
-rw-r--r-- | designate/tests/test_api/test_v2/test_api.py | 28 |
3 files changed, 29 insertions, 4 deletions
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) |