Negative test cases for "Create a zone"

1) test_no_valid_zone_name
   Attempts to create a Zone using not valid name
2) test_no_valid_email
   Attempts to create a zone using not valid email
3) test_no_valid_ttl
   Attempts to create a zone using not valid TTL
4) test_huge_size_description
   Trying to create a zone with huge size description.

Change-Id: Ia3bb45f3ba33e8b1b7de97bb6d04d7ed00cb7a21
diff --git a/designate_tempest_plugin/services/dns/v2/json/zones_client.py b/designate_tempest_plugin/services/dns/v2/json/zones_client.py
index 9c5c056..29f0ab3 100644
--- a/designate_tempest_plugin/services/dns/v2/json/zones_client.py
+++ b/designate_tempest_plugin/services/dns/v2/json/zones_client.py
@@ -44,10 +44,14 @@
         :return: A tuple with the server response and the created zone.
         """
         zone = {
-            'name': name or dns_data_utils.rand_zone_name(),
-            'email': email or dns_data_utils.rand_email(),
-            'ttl': ttl or dns_data_utils.rand_ttl(),
-            'description': description or data_utils.rand_name('test-zone'),
+            'name': name or dns_data_utils.rand_zone_name()
+            if name != '' else '',
+            'email': email or dns_data_utils.rand_email()
+            if email != '' else '',
+            'ttl': ttl or dns_data_utils.rand_ttl()
+            if ttl != 0 else 0,
+            'description': description or data_utils.rand_name('test-zone')
+            if description != '' else '',
             'attributes': attributes or {
                 'attribute_key': data_utils.rand_name('attribute_value')}
         }
diff --git a/designate_tempest_plugin/tests/api/v2/test_zones.py b/designate_tempest_plugin/tests/api/v2/test_zones.py
index 94e162f..fdb08b9 100644
--- a/designate_tempest_plugin/tests/api/v2/test_zones.py
+++ b/designate_tempest_plugin/tests/api/v2/test_zones.py
@@ -291,3 +291,58 @@
         LOG.info('Create a zone as an alt user with existing superdomain')
         self.assertRaises(lib_exc.Forbidden,
             self.alt_client.create_zone, name=zone_name)
+
+
+class ZonesNegativeTest(BaseZonesTest):
+    @classmethod
+    def setup_credentials(cls):
+        # Do not create network resources for these test.
+        cls.set_network_resources()
+        super(ZonesNegativeTest, cls).setup_credentials()
+
+    @classmethod
+    def setup_clients(cls):
+        super(ZonesNegativeTest, cls).setup_clients()
+        cls.client = cls.os_primary.zones_client
+
+    @decorators.idempotent_id('551853c0-8593-11eb-8c8a-74e5f9e2a801')
+    def test_no_valid_zone_name(self):
+        no_valid_names = ['a' * 1000, '___', '!^%&^#%^!@#', 'ggg', '.a', '']
+        for name in no_valid_names:
+            LOG.info('Trying to create a zone named: {} '.format(name))
+            self.assertRaisesDns(
+                lib_exc.BadRequest, 'invalid_object', 400,
+                self.client.create_zone, name=name)
+
+    @decorators.idempotent_id('551853c0-8593-11eb-8c8a-74e5f9e2a801')
+    def test_no_valid_email(self):
+        no_valid_emails = [
+            'zahlabut#gmail.com', '123456', '___', '', '*&^*^%$']
+        for email in no_valid_emails:
+            LOG.info(
+                'Trying to create a zone using: {} as email'
+                ' value: '.format(email))
+            self.assertRaisesDns(
+                lib_exc.BadRequest, 'invalid_object', 400,
+                self.client.create_zone, email=email)
+
+    @decorators.idempotent_id('551853c0-8593-11eb-8c8a-74e5f9e2a801')
+    def test_no_valid_ttl(self):
+        no_valid_tls = ['zahlabut', -60000,
+                        2147483647 + 10]  # Max valid TTL is 2147483647
+
+        for ttl in no_valid_tls:
+            LOG.info(
+                'Trying to create a zone using: {} as TTL'
+                ' value: '.format(ttl))
+            self.assertRaisesDns(
+                lib_exc.BadRequest, 'invalid_object', 400,
+                self.client.create_zone, ttl=ttl)
+
+    @decorators.idempotent_id('a3b0a928-a682-11eb-9899-74e5f9e2a801')
+    def test_huge_size_description(self):
+        LOG.info('Trying to create a zone using huge size description')
+        self.assertRaisesDns(
+            lib_exc.BadRequest, 'invalid_object', 400,
+            self.client.create_zone,
+            description=dns_data_utils.rand_zone_name() * 10000)