Add zones ownership transfer accept to Designate tempest plugin
This patch adds zone transfer_accepts_client's methods and tests
to Designate tempest plugin.
Change-Id: I04ae928dbfc54dc4db8cfca5c2da62183858231f
Partially-Implements: blueprint designate-tempest-plugin
diff --git a/designate_tempest_plugin/clients.py b/designate_tempest_plugin/clients.py
index 5cdb39e..9986a43 100644
--- a/designate_tempest_plugin/clients.py
+++ b/designate_tempest_plugin/clients.py
@@ -40,6 +40,8 @@
QueryClient
from designate_tempest_plugin.services.dns.v2.json.transfer_request_client \
import TransferRequestClient
+from designate_tempest_plugin.services.dns.v2.json.transfer_accepts_client \
+ import TransferAcceptClient
CONF = config.CONF
@@ -96,3 +98,5 @@
)
self.transfer_request_client = TransferRequestClient(
self.auth_provider, **params)
+ self.transfer_accept_client = TransferAcceptClient(
+ self.auth_provider, **params)
diff --git a/designate_tempest_plugin/services/dns/v2/json/transfer_accepts_client.py b/designate_tempest_plugin/services/dns/v2/json/transfer_accepts_client.py
new file mode 100644
index 0000000..fe0fd0f
--- /dev/null
+++ b/designate_tempest_plugin/services/dns/v2/json/transfer_accepts_client.py
@@ -0,0 +1,49 @@
+# Copyright 2016 NEC Corporation. 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 designate_tempest_plugin.services.dns.v2.json import base
+
+
+class TransferAcceptClient(base.DnsClientV2Base):
+
+ @base.handle_errors
+ def create_transfer_accept(self, transfer_accept_data,
+ params=None):
+ """Create a zone transfer_accept.
+ :param transfer_accept_data: A python dictionary representing
+ data for the zone transfer accept.
+ :param params: A Python dict that represents the query paramaters to
+ include in the accept URI.
+ :return: Serialized accepted zone transfer as a dictionary.
+ """
+
+ transfer_accept_uri = 'zones/tasks/transfer_accepts'
+ resp, body = self._create_request(
+ transfer_accept_uri, transfer_accept_data, params=params)
+
+ # Create Transfer accept should Return a HTTP 201
+ self.expected_success(201, resp.status)
+
+ return resp, body
+
+ @base.handle_errors
+ def show_transfer_accept(self, uuid, params=None):
+ """Gets a specific accepted zone transfer..
+ :param uuid: Unique identifier of the transfer_accept.
+ :param params: A Python dict that represents the query paramaters to
+ include in the accept URI.
+ :return: Serialized accepted zone transfer as a dictionary.
+ """
+ return self._show_request(
+ 'zones/tasks/transfer_accepts', uuid, params=params)
diff --git a/designate_tempest_plugin/tests/api/v2/test_transfer_accepts.py b/designate_tempest_plugin/tests/api/v2/test_transfer_accepts.py
new file mode 100644
index 0000000..cdf9388
--- /dev/null
+++ b/designate_tempest_plugin/tests/api/v2/test_transfer_accepts.py
@@ -0,0 +1,85 @@
+# Copyright 2016 NEC Corporation. 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 oslo_log import log as logging
+from tempest import test
+
+from designate_tempest_plugin.tests import base
+
+LOG = logging.getLogger(__name__)
+
+
+class BaseTransferAcceptTest(base.BaseDnsV2Test):
+ excluded_keys = ['created_at', 'updated_at', 'key', 'links',
+ 'zone_name']
+
+
+class TransferAcceptTest(BaseTransferAcceptTest):
+ @classmethod
+ def setup_clients(cls):
+ super(TransferAcceptTest, cls).setup_clients()
+
+ cls.zone_client = cls.os.zones_client
+ cls.request_client = cls.os.transfer_request_client
+ cls.client = cls.os.transfer_accept_client
+
+ @test.attr(type='smoke')
+ @test.idempotent_id('1c6baf97-a83e-4d2e-a5d8-9d37fb7808f3')
+ def test_create_transfer_accept(self):
+ LOG.info('Create a zone')
+ _, zone = self.zone_client.create_zone()
+ self.addCleanup(self.zone_client.delete_zone, zone['id'])
+
+ LOG.info('Create a zone transfer_request')
+ _, transfer_request = self.request_client.create_transfer_request(
+ zone['id'])
+ self.addCleanup(self.request_client.delete_transfer_request,
+ transfer_request['id'])
+
+ data = {
+ "key": transfer_request['key'],
+ "zone_transfer_request_id": transfer_request['id']
+ }
+ LOG.info('Create a zone transfer_accept')
+ _, transfer_accept = self.client.create_transfer_accept(data)
+
+ LOG.info('Ensure we respond with ACTIVE status')
+ self.assertEqual('COMPLETE', transfer_accept['status'])
+
+ @test.attr(type='smoke')
+ @test.idempotent_id('37c6afbb-3ea3-4fd8-94ea-a426244f019a')
+ def test_show_transfer_accept(self):
+ LOG.info('Create a zone')
+ _, zone = self.zone_client.create_zone()
+ self.addCleanup(self.zone_client.delete_zone, zone['id'])
+
+ LOG.info('Create a zone transfer_request')
+ _, transfer_request = self.request_client.create_transfer_request(
+ zone['id'])
+ self.addCleanup(self.request_client.delete_transfer_request,
+ transfer_request['id'])
+
+ data = {
+ "key": transfer_request['key'],
+ "zone_transfer_request_id": transfer_request['id']
+ }
+
+ LOG.info('Create a zone transfer_accept')
+ _, transfer_accept = self.client.create_transfer_accept(data)
+
+ LOG.info('Fetch the transfer_accept')
+ _, body = self.client.show_transfer_accept(transfer_accept['id'])
+
+ LOG.info('Ensure the fetched response matches the '
+ 'created transfer_accept')
+ self.assertExpected(transfer_accept, body, self.excluded_keys)