diff options
| author | Igor Malinovskiy <u.glide@gmail.com> | 2020-04-26 20:25:50 +0300 |
|---|---|---|
| committer | Michael Johnson <johnsomor@gmail.com> | 2023-02-13 20:51:32 +0000 |
| commit | bc39d23ff5ff45e7669cb4be9d2c28b9242cf9d9 (patch) | |
| tree | 936488d5239b9ef1a7890c06006c38ec42bd3bc9 /designateclient/functionaltests/v2 | |
| parent | 483e0d16c6b357a610634ad5f7db9ab61b41d353 (diff) | |
| download | python-designateclient-5.2.0.tar.gz | |
Add shared zone commands5.2.0
Co-Authored-By: Michael Johnson <johnsomor@gmail.com>
Change-Id: Iea92371176d9126205384624a18a9097acb3daef
Partial-Bug: #1714088
Depends-On: https://review.opendev.org/#/c/726334/
Diffstat (limited to 'designateclient/functionaltests/v2')
| -rw-r--r-- | designateclient/functionaltests/v2/fixtures.py | 22 | ||||
| -rw-r--r-- | designateclient/functionaltests/v2/test_shared_zone.py | 73 |
2 files changed, 95 insertions, 0 deletions
diff --git a/designateclient/functionaltests/v2/fixtures.py b/designateclient/functionaltests/v2/fixtures.py index cc5a83b..c72a18b 100644 --- a/designateclient/functionaltests/v2/fixtures.py +++ b/designateclient/functionaltests/v2/fixtures.py @@ -228,3 +228,25 @@ class BlacklistFixture(BaseFixture): client.zone_blacklist_delete(blacklist_id) except CommandFailed: pass + + +class SharedZoneFixture(BaseFixture): + """See DesignateCLI.recordset_create for __init__ args""" + + def __init__(self, zone, *args, **kwargs): + super(SharedZoneFixture, self).__init__(*args, **kwargs) + self.zone = zone + + def _setUp(self): + super(SharedZoneFixture, self)._setUp() + self.zone_share = self.client.zone_share(zone_id=self.zone.id, + *self.args, **self.kwargs) + self.addCleanup(self.cleanup_shared_zone, self.client, self.zone.id, + self.zone_share.id) + + @classmethod + def cleanup_shared_zone(cls, client, zone_id, shared_zone_id): + try: + client.unshare_zone(zone_id, shared_zone_id) + except CommandFailed: + pass diff --git a/designateclient/functionaltests/v2/test_shared_zone.py b/designateclient/functionaltests/v2/test_shared_zone.py new file mode 100644 index 0000000..0e8b392 --- /dev/null +++ b/designateclient/functionaltests/v2/test_shared_zone.py @@ -0,0 +1,73 @@ +""" + Copyright 2020 Cloudification GmbH. All rights reserved. + +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 designateclient.functionaltests.base import BaseDesignateTest +from designateclient.functionaltests.client import DesignateCLI +from designateclient.functionaltests.datagen import random_zone_name +from designateclient.functionaltests.v2.fixtures import SharedZoneFixture +from designateclient.functionaltests.v2.fixtures import ZoneFixture + + +class TestSharedZone(BaseDesignateTest): + + def setUp(self): + super(TestSharedZone, self).setUp() + self.ensure_tld_exists('com') + fixture = self.useFixture(ZoneFixture( + name=random_zone_name(), + email='test@example.com', + )) + self.zone = fixture.zone + self.target_client = DesignateCLI.as_user('alt') + + def test_list_shared_zones(self): + shared_zone = self.useFixture(SharedZoneFixture( + zone_id=self.zone.id, + target_tenant_id=self.target_client.project_id + )).zone_share + + shared_zones = self.clients.shared_zone_list(self.zone.id) + self.assertGreater(len(shared_zones), 0) + self.assertTrue(self._is_entity_in_list(shared_zone, shared_zones)) + + def test_share_and_show_shared_zone(self): + shared_zone = self.useFixture(SharedZoneFixture( + zone_id=self.zone.id, + target_tenant_id=self.target_client.project_id + )).zone_share + + fetched_shared_zone = self.clients.shared_zone_show(self.zone.id, + shared_zone.id) + + self.assertEqual( + shared_zone.created_at, fetched_shared_zone.created_at) + self.assertEqual(shared_zone.id, fetched_shared_zone.id) + self.assertEqual( + shared_zone.project_id, fetched_shared_zone.project_id) + self.assertEqual(shared_zone.zone_id, fetched_shared_zone.zone_id) + + def test_unshare_zone(self): + shared_zone = self.useFixture(SharedZoneFixture( + zone_id=self.zone.id, + target_tenant_id=self.target_client.project_id + )).zone_share + + shared_zones = self.clients.shared_zone_list(self.zone.id) + self.assertTrue(self._is_entity_in_list(shared_zone, shared_zones)) + + self.clients.unshare_zone(self.zone.id, shared_zone.id) + + shared_zones = self.clients.shared_zone_list(self.zone.id) + self.assertFalse(self._is_entity_in_list(shared_zone, shared_zones)) |
