Migrate negative tests for pools, tlds, blacklists

This adds tests that check Designate's behavior on an invalid uuid and
on a valid but not found uuid.

Change-Id: Ic93b8c1bbfc30792cbb071df797e11e17cc99033
diff --git a/designate_tempest_plugin/tests/api/v2/test_blacklists.py b/designate_tempest_plugin/tests/api/v2/test_blacklists.py
index 271c65d..fc91471 100644
--- a/designate_tempest_plugin/tests/api/v2/test_blacklists.py
+++ b/designate_tempest_plugin/tests/api/v2/test_blacklists.py
@@ -108,3 +108,84 @@
         LOG.info('Ensure we response with updated values')
         self.assertEqual(pattern, body['pattern'])
         self.assertEqual(description, body['description'])
+
+
+class TestBlacklistNotFoundAdmin(BaseBlacklistsTest):
+
+    credentials = ["admin"]
+
+    @classmethod
+    def setup_clients(cls):
+        super(TestBlacklistNotFoundAdmin, cls).setup_clients()
+        cls.admin_client = cls.os_adm.blacklists_client
+
+    @test.attr(type='smoke')
+    @decorators.idempotent_id('9d65b638-fe98-47a8-853f-fa9244d144cc')
+    def test_show_blacklist_404(self):
+        e = self.assertRaises(lib_exc.NotFound,
+                              self.admin_client.show_blacklist,
+                              data_utils.rand_uuid())
+        self.assertBlacklist404(e.resp, e.resp_body)
+
+    @test.attr(type='smoke')
+    @decorators.idempotent_id('a9e12415-5040-4fba-905c-95d201fcfd3b')
+    def test_update_blacklist_404(self):
+        e = self.assertRaises(lib_exc.NotFound,
+                              self.admin_client.update_blacklist,
+                              data_utils.rand_uuid())
+        self.assertBlacklist404(e.resp, e.resp_body)
+
+    @test.attr(type='smoke')
+    @decorators.idempotent_id('b1132586-bf06-47a6-9f6f-3bab6a2c1932')
+    def test_delete_blacklist_404(self):
+        e = self.assertRaises(lib_exc.NotFound,
+                              self.admin_client.delete_blacklist,
+                              data_utils.rand_uuid())
+        self.assertBlacklist404(e.resp, e.resp_body)
+
+    def assertBlacklist404(self, resp, resp_body):
+        self.assertEqual(404, resp.status)
+        self.assertEqual(404, resp_body['code'])
+        self.assertEqual("blacklist_not_found", resp_body['type'])
+        self.assertEqual("Could not find Blacklist", resp_body['message'])
+
+
+class TestBlacklistInvalidIdAdmin(BaseBlacklistsTest):
+
+    credentials = ["admin"]
+
+    @classmethod
+    def setup_clients(cls):
+        super(TestBlacklistInvalidIdAdmin, cls).setup_clients()
+        cls.admin_client = cls.os_adm.blacklists_client
+
+    @test.attr(type='smoke')
+    @decorators.idempotent_id('c7bae53f-2edc-45d8-b254-8a81482728c1')
+    def test_show_blacklist_invalid_uuid(self):
+        e = self.assertRaises(lib_exc.BadRequest,
+                              self.admin_client.show_blacklist,
+                              'foo')
+        self.assertBlacklistInvalidId(e.resp, e.resp_body)
+
+    @test.attr(type='smoke')
+    @decorators.idempotent_id('c57b97da-ca87-44b5-9f40-a099937433bf')
+    def test_update_blacklist_invalid_uuid(self):
+        e = self.assertRaises(lib_exc.BadRequest,
+                              self.admin_client.update_blacklist,
+                              'foo')
+        self.assertBlacklistInvalidId(e.resp, e.resp_body)
+
+    @test.attr(type='smoke')
+    @decorators.idempotent_id('5d62a026-13e4-48b9-9773-1780660c5920')
+    def test_delete_blacklist_invalid_uuid(self):
+        e = self.assertRaises(lib_exc.BadRequest,
+                              self.admin_client.delete_blacklist,
+                              'foo')
+        self.assertBlacklistInvalidId(e.resp, e.resp_body)
+
+    def assertBlacklistInvalidId(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 blacklist_id: foo",
+                         resp_body['message'])
diff --git a/designate_tempest_plugin/tests/api/v2/test_pool.py b/designate_tempest_plugin/tests/api/v2/test_pool.py
index 8411f6e..5746ce0 100644
--- a/designate_tempest_plugin/tests/api/v2/test_pool.py
+++ b/designate_tempest_plugin/tests/api/v2/test_pool.py
@@ -18,6 +18,7 @@
 from tempest import test
 from tempest.lib import decorators
 from tempest.lib import exceptions as lib_exc
+from tempest.lib.common.utils import data_utils
 
 from designate_tempest_plugin.tests import base
 
@@ -121,3 +122,84 @@
 
         self.assertRaises(lib_exc.NotFound,
             lambda: self.admin_client.get(uri))
+
+
+class TestPoolNotFoundAdmin(BasePoolTest):
+
+    credentials = ["admin"]
+
+    @classmethod
+    def setup_clients(cls):
+        super(TestPoolNotFoundAdmin, cls).setup_clients()
+        cls.admin_client = cls.os_adm.pool_client
+
+    @test.attr(type='smoke')
+    @decorators.idempotent_id('56281b2f-dd5a-4376-8c32-aba771062fa5')
+    def test_show_pool_404(self):
+        e = self.assertRaises(lib_exc.NotFound,
+                              self.admin_client.show_pool,
+                              data_utils.rand_uuid())
+        self.assertPool404(e.resp, e.resp_body)
+
+    @test.attr(type='smoke')
+    @decorators.idempotent_id('10fba3c2-9972-479c-ace1-8f7eac7c159f')
+    def test_update_pool_404(self):
+        e = self.assertRaises(lib_exc.NotFound,
+                              self.admin_client.update_pool,
+                              data_utils.rand_uuid())
+        self.assertPool404(e.resp, e.resp_body)
+
+    @test.attr(type='smoke')
+    @decorators.idempotent_id('96132295-896b-4de3-8f86-cc2ee513fdad')
+    def test_delete_pool_404(self):
+        e = self.assertRaises(lib_exc.NotFound,
+                              self.admin_client.delete_pool,
+                              data_utils.rand_uuid())
+        self.assertPool404(e.resp, e.resp_body)
+
+    def assertPool404(self, resp, resp_body):
+        self.assertEqual(404, resp.status)
+        self.assertEqual(404, resp_body['code'])
+        self.assertEqual("pool_not_found", resp_body['type'])
+        self.assertEqual("Could not find Pool", resp_body['message'])
+
+
+class TestPoolInvalidIdAdmin(BasePoolTest):
+
+    credentials = ["admin"]
+
+    @classmethod
+    def setup_clients(cls):
+        super(TestPoolInvalidIdAdmin, cls).setup_clients()
+        cls.admin_client = cls.os_adm.pool_client
+
+    @test.attr(type='smoke')
+    @decorators.idempotent_id('081d0188-42a7-4953-af0e-b022960715e2')
+    def test_show_pool_invalid_uuid(self):
+        e = self.assertRaises(lib_exc.BadRequest,
+                              self.admin_client.show_pool,
+                              'foo')
+        self.assertPoolInvalidId(e.resp, e.resp_body)
+
+    @test.attr(type='smoke')
+    @decorators.idempotent_id('f4ab4f5a-d7f0-4758-b232-8338f02d7c5c')
+    def test_update_pool_invalid_uuid(self):
+        e = self.assertRaises(lib_exc.BadRequest,
+                              self.admin_client.update_pool,
+                              'foo')
+        self.assertPoolInvalidId(e.resp, e.resp_body)
+
+    @test.attr(type='smoke')
+    @decorators.idempotent_id('bf5ad3be-2e79-439d-b247-902fe198143b')
+    def test_delete_pool_invalid_uuid(self):
+        e = self.assertRaises(lib_exc.BadRequest,
+                              self.admin_client.delete_pool,
+                              'foo')
+        self.assertPoolInvalidId(e.resp, e.resp_body)
+
+    def assertPoolInvalidId(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 pool_id: foo",
+                         resp_body['message'])
diff --git a/designate_tempest_plugin/tests/api/v2/test_tld.py b/designate_tempest_plugin/tests/api/v2/test_tld.py
index e4d82f7..ee74d86 100644
--- a/designate_tempest_plugin/tests/api/v2/test_tld.py
+++ b/designate_tempest_plugin/tests/api/v2/test_tld.py
@@ -16,6 +16,7 @@
 from tempest import test
 from tempest.lib import decorators
 from tempest.lib import exceptions as lib_exc
+from tempest.lib.common.utils import data_utils
 
 from designate_tempest_plugin.tests import base
 
@@ -119,3 +120,84 @@
 
         self.assertRaises(lib_exc.NotFound,
             lambda: self.admin_client.get(uri))
+
+
+class TestTldNotFoundAdmin(BaseTldTest):
+
+    credentials = ["admin"]
+
+    @classmethod
+    def setup_clients(cls):
+        super(TestTldNotFoundAdmin, cls).setup_clients()
+        cls.admin_client = cls.os_adm.tld_client
+
+    @test.attr(type='smoke')
+    @decorators.idempotent_id('b237d5ee-0d76-4294-a3b6-c2f8bf4b0e30')
+    def test_show_tld_404(self):
+        e = self.assertRaises(lib_exc.NotFound,
+                              self.admin_client.show_tld,
+                              data_utils.rand_uuid())
+        self.assertTld404(e.resp, e.resp_body)
+
+    @test.attr(type='smoke')
+    @decorators.idempotent_id('3d128772-7f52-4473-b569-51ae8294667b')
+    def test_update_tld_404(self):
+        e = self.assertRaises(lib_exc.NotFound,
+                              self.admin_client.update_tld,
+                              data_utils.rand_uuid())
+        self.assertTld404(e.resp, e.resp_body)
+
+    @test.attr(type='smoke')
+    @decorators.idempotent_id('18e465e7-5c7d-4775-acef-bd12a8db1095')
+    def test_delete_tld_404(self):
+        e = self.assertRaises(lib_exc.NotFound,
+                              self.admin_client.delete_tld,
+                              data_utils.rand_uuid())
+        self.assertTld404(e.resp, e.resp_body)
+
+    def assertTld404(self, resp, resp_body):
+        self.assertEqual(404, resp.status)
+        self.assertEqual(404, resp_body['code'])
+        self.assertEqual("tld_not_found", resp_body['type'])
+        self.assertEqual("Could not find Tld", resp_body['message'])
+
+
+class TestTldInvalidIdAdmin(BaseTldTest):
+
+    credentials = ["admin"]
+
+    @classmethod
+    def setup_clients(cls):
+        super(TestTldInvalidIdAdmin, cls).setup_clients()
+        cls.admin_client = cls.os_adm.tld_client
+
+    @test.attr(type='smoke')
+    @decorators.idempotent_id('f9ec0730-57ff-4720-8d06-e11d377c7cfc')
+    def test_show_tld_invalid_uuid(self):
+        e = self.assertRaises(lib_exc.BadRequest,
+                              self.admin_client.show_tld,
+                              'foo')
+        self.assertTldInvalidId(e.resp, e.resp_body)
+
+    @test.attr(type='smoke')
+    @decorators.idempotent_id('13dc6518-b479-4502-90f5-f5a5ecc8b1fb')
+    def test_update_tld_invalid_uuid(self):
+        e = self.assertRaises(lib_exc.BadRequest,
+                              self.admin_client.update_tld,
+                              'foo')
+        self.assertTldInvalidId(e.resp, e.resp_body)
+
+    @test.attr(type='smoke')
+    @decorators.idempotent_id('6a6fc9db-9a73-4ffc-831a-172e1cbc7394')
+    def test_delete_tld_invalid_uuid(self):
+        e = self.assertRaises(lib_exc.BadRequest,
+                              self.admin_client.delete_tld,
+                              'foo')
+        self.assertTldInvalidId(e.resp, e.resp_body)
+
+    def assertTldInvalidId(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 tld_id: foo",
+                         resp_body['message'])