Merge "Add negative testcases for ownership transfer_request and tsigkey"
diff --git a/designate_tempest_plugin/tests/api/v2/test_transfer_request.py b/designate_tempest_plugin/tests/api/v2/test_transfer_request.py
index 7b9af10..9bc3897 100644
--- a/designate_tempest_plugin/tests/api/v2/test_transfer_request.py
+++ b/designate_tempest_plugin/tests/api/v2/test_transfer_request.py
@@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
+from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc
@@ -125,3 +126,73 @@
self.assertRaises(lib_exc.NotFound,
lambda: self.client.get(uri))
+
+
+class TestTransferRequestNotFound(BaseTransferRequestTest):
+
+ @classmethod
+ def setup_clients(cls):
+ super(TestTransferRequestNotFound, cls).setup_clients()
+ cls.client = cls.os.transfer_request_client
+
+ @decorators.idempotent_id('d255f72f-ba24-43df-9dba-011ed7f4625d')
+ def test_show_transfer_request_404(self):
+ e = self.assertRaises(lib_exc.NotFound,
+ self.client.show_transfer_request,
+ data_utils.rand_uuid())
+ self.assertTransferRequest404(e.resp, e.resp_body)
+
+ @decorators.idempotent_id('9ff383fb-c31d-4c6f-8085-7b261e401223')
+ def test_update_transfer_request_404(self):
+ e = self.assertRaises(lib_exc.NotFound,
+ self.client.update_transfer_request,
+ data_utils.rand_uuid())
+ self.assertTransferRequest404(e.resp, e.resp_body)
+
+ @decorators.idempotent_id('5a4a0755-c01d-448f-b856-b081b96ae77e')
+ def test_delete_transfer_request_404(self):
+ e = self.assertRaises(lib_exc.NotFound,
+ self.client.delete_transfer_request,
+ data_utils.rand_uuid())
+ self.assertTransferRequest404(e.resp, e.resp_body)
+
+ def assertTransferRequest404(self, resp, resp_body):
+ self.assertEqual(404, resp.status)
+ self.assertEqual(404, resp_body['code'])
+ self.assertEqual("zone_transfer_request_not_found", resp_body['type'])
+ self.assertEqual("Could not find ZoneTransferRequest",
+ resp_body['message'])
+
+
+class TestTransferRequestInvalidId(BaseTransferRequestTest):
+
+ @classmethod
+ def setup_clients(cls):
+ super(TestTransferRequestInvalidId, cls).setup_clients()
+ cls.client = cls.os.transfer_request_client
+
+ @decorators.idempotent_id('2205dd19-ecc7-4c68-9e89-63c47d642b07')
+ def test_show_transfer_request_invalid_uuid(self):
+ e = self.assertRaises(lib_exc.BadRequest,
+ self.client.show_transfer_request,
+ 'foo')
+ self.assertTransferRequestInvalidId(e.resp, e.resp_body)
+
+ @decorators.idempotent_id('af0ce46f-10be-4cce-a1d5-1b5c2a39fb97')
+ def test_update_transfer_request_invalid_uuid(self):
+ e = self.assertRaises(lib_exc.BadRequest,
+ self.client.update_transfer_request,
+ 'foo')
+ self.assertTransferRequestInvalidId(e.resp, e.resp_body)
+
+ @decorators.idempotent_id('1728dca5-01f1-45f4-b59d-7a981d479394')
+ def test_delete_transfer_request_invalid_uuid(self):
+ e = self.assertRaises(lib_exc.BadRequest,
+ self.client.delete_transfer_request,
+ 'foo')
+ self.assertTransferRequestInvalidId(e.resp, e.resp_body)
+
+ def assertTransferRequestInvalidId(self, resp, resp_body):
+ self.assertEqual(400, resp.status)
+ self.assertEqual(400, resp_body['code'])
+ self.assertEqual("invalid_uuid", resp_body['type'])
diff --git a/designate_tempest_plugin/tests/api/v2/test_tsigkey.py b/designate_tempest_plugin/tests/api/v2/test_tsigkey.py
index 2e4ffa9..129c576 100644
--- a/designate_tempest_plugin/tests/api/v2/test_tsigkey.py
+++ b/designate_tempest_plugin/tests/api/v2/test_tsigkey.py
@@ -13,6 +13,7 @@
# under the License.
from oslo_log import log as logging
+from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc
@@ -129,3 +130,78 @@
self.assertRaises(lib_exc.NotFound,
lambda: self.admin_client.get(uri))
+
+
+class TestTsigkeyNotFoundAdmin(BaseTsigkeyTest):
+
+ credentials = ["admin"]
+
+ @classmethod
+ def setup_clients(cls):
+ super(TestTsigkeyNotFoundAdmin, cls).setup_clients()
+ cls.admin_client = cls.os_adm.tsigkey_client
+
+ @decorators.idempotent_id('824c9b49-edc5-4282-929e-467a158d23e4')
+ def test_show_tsigkey_404(self):
+ e = self.assertRaises(lib_exc.NotFound,
+ self.admin_client.show_tsigkey,
+ data_utils.rand_uuid())
+ self.assertTsigkey404(e.resp, e.resp_body)
+
+ @decorators.idempotent_id('4ef3493a-ee66-4c62-b070-c57fa9568b69')
+ def test_update_tsigkey_404(self):
+ e = self.assertRaises(lib_exc.NotFound,
+ self.admin_client.update_tsigkey,
+ data_utils.rand_uuid())
+ self.assertTsigkey404(e.resp, e.resp_body)
+
+ @decorators.idempotent_id('ba438ede-4823-4922-8f4c-8de278f3d454')
+ def test_delete_tsigkey_404(self):
+ e = self.assertRaises(lib_exc.NotFound,
+ self.admin_client.delete_tsigkey,
+ data_utils.rand_uuid())
+ self.assertTsigkey404(e.resp, e.resp_body)
+
+ def assertTsigkey404(self, resp, resp_body):
+ self.assertEqual(404, resp.status)
+ self.assertEqual(404, resp_body['code'])
+ self.assertEqual("tsigkey_not_found", resp_body['type'])
+ self.assertEqual("Could not find TsigKey", resp_body['message'])
+
+
+class TestTsigkeyInvalidIdAdmin(BaseTsigkeyTest):
+
+ credentials = ["admin"]
+
+ @classmethod
+ def setup_clients(cls):
+ super(TestTsigkeyInvalidIdAdmin, cls).setup_clients()
+ cls.admin_client = cls.os_adm.tsigkey_client
+
+ @decorators.idempotent_id('2a8dfc75-9884-4b1c-8f1f-ed835d96f2fe')
+ def test_show_tsigkey_invalid_uuid(self):
+ e = self.assertRaises(lib_exc.BadRequest,
+ self.admin_client.show_tsigkey,
+ 'foo')
+ self.assertTsigkeyInvalidId(e.resp, e.resp_body)
+
+ @decorators.idempotent_id('2befa10f-fc42-4ae9-9276-672e23f045f2')
+ def test_update_tsigkey_invalid_uuid(self):
+ e = self.assertRaises(lib_exc.BadRequest,
+ self.admin_client.update_tsigkey,
+ 'foo')
+ self.assertTsigkeyInvalidId(e.resp, e.resp_body)
+
+ @decorators.idempotent_id('55c2fea0-ead6-44c7-8bb1-05111412afdd')
+ def test_delete_tsigkey_invalid_uuid(self):
+ e = self.assertRaises(lib_exc.BadRequest,
+ self.admin_client.delete_tsigkey,
+ 'foo')
+ self.assertTsigkeyInvalidId(e.resp, e.resp_body)
+
+ def assertTsigkeyInvalidId(self, resp, resp_body):
+ self.assertEqual(400, resp.status)
+ self.assertEqual(400, resp_body['code'])
+ self.assertEqual("invalid_uuid", resp_body['type'])
+ self.assertEqual("Invalid UUID tsigkey_id: foo",
+ resp_body['message'])