Merge "New test cases for TLD tests suite"
diff --git a/designate_tempest_plugin/tests/api/v2/test_designate_limits.py b/designate_tempest_plugin/tests/api/v2/test_designate_limits.py
index 9ea7fd3..2cb9d9e 100644
--- a/designate_tempest_plugin/tests/api/v2/test_designate_limits.py
+++ b/designate_tempest_plugin/tests/api/v2/test_designate_limits.py
@@ -14,6 +14,8 @@
 from oslo_log import log as logging
 from tempest import config
 from tempest.lib import decorators
+from tempest.lib import exceptions as lib_exc
+
 
 from designate_tempest_plugin.tests import base
 
@@ -22,7 +24,7 @@
 
 
 class DesignateLimit(base.BaseDnsV2Test):
-    credentials = ["admin", "system_admin"]
+    credentials = ["admin", "system_admin", "primary", "alt"]
 
     @classmethod
     def setup_credentials(cls):
@@ -38,15 +40,17 @@
                                 DesignateLimitClient())
         else:
             cls.admin_client = cls.os_admin.dns_v2.DesignateLimitClient()
+        cls.primary_client = cls.os_primary.dns_v2.DesignateLimitClient()
+        cls.alt_client = cls.os_alt.dns_v2.DesignateLimitClient()
 
     @decorators.idempotent_id('828572be-8662-11eb-8ff2-74e5f9e2a801')
-    def test_list_designate_limits(self):
+    def test_list_designate_limits_as_primary_user(self):
         expected_default_limits_fields = [
             "max_page_limit", "max_recordset_name_length",
             "max_recordset_records", "max_zone_name_length",
             "max_zone_records", "max_zone_recordsets",
             "max_zones", "min_ttl"].sort()
-        project_limits = self.admin_client.list_designate_limits()
+        project_limits = self.primary_client.list_designate_limits()
         LOG.info(
             'Retrieved designate limits are: {} '.format(project_limits))
         self.assertEqual(
@@ -55,3 +59,46 @@
             'Retrieved fields: {} are not as expected: {} '.format(
                 list(project_limits.keys()).sort(),
                 expected_default_limits_fields))
+
+    @decorators.idempotent_id('828572be-8662-11eb-8ff2-74e5f9e2a801')
+    def test_list_designate_impersonate_another_user_as_admin(self):
+        primary_project_limits = self.primary_client.list_designate_limits()
+        LOG.info(
+            'Retrieved designate limits for Primary user are: {} '.format(
+                primary_project_limits))
+        admin_sudo_project_limits = self.admin_client.list_designate_limits(
+            headers={'x-auth-sudo-project-id': self.primary_client.project_id})
+        LOG.info(
+            'Retrieved designate limits for Admin user impersonates '
+            'Primary user are: {} '.format(admin_sudo_project_limits))
+        self.assertEqual(
+            primary_project_limits, admin_sudo_project_limits,
+            'Failed, Admin user should receive the same values for '
+            'Designate limits as a Primary tenant did.')
+
+    @decorators.idempotent_id('5975fee0-d430-11eb-aa4d-74e5f9e2a801')
+    def test_list_designate_impersonate_another_user_as_alt(self):
+        self.assertRaises(
+            lib_exc.Forbidden, self.alt_client.list_designate_limits,
+            headers={'x-auth-sudo-project-id': self.primary_client.project_id})
+
+    @decorators.idempotent_id('828572be-8662-11eb-8ff2-74e5f9e2a801')
+    @decorators.skip_because(bug="1933444")
+    def test_list_designate_limits_all_projects(self):
+        existing_project_ids = [
+            self.primary_client.project_id, self.alt_client.project_id]
+        LOG.info('Project IDs we would expect to receive with Admin user '
+                 'uses: "x-auth-all-projects" HTTP header '
+                 'are {}: '.format(existing_project_ids))
+        all_project_limits = self.admin_client.list_designate_limits(
+            headers={'x-auth-all-projects': True})
+        LOG.info(
+            'Retrieved designate limits by Admin user for all projects '
+            'are: '.format(all_project_limits))
+        received_project_ids = [
+            item['project_id'] for item in all_project_limits]
+        for project_id in existing_project_ids:
+            self.assertIn(
+                project_id, received_project_ids,
+                'Failed, expected project_id:{} is missing in:{} '.format(
+                    project_id, received_project_ids))
diff --git a/designate_tempest_plugin/tests/api/v2/test_zone_tasks.py b/designate_tempest_plugin/tests/api/v2/test_zone_tasks.py
index 437c222..bbeea75 100644
--- a/designate_tempest_plugin/tests/api/v2/test_zone_tasks.py
+++ b/designate_tempest_plugin/tests/api/v2/test_zone_tasks.py
@@ -13,6 +13,7 @@
 # under the License.
 
 from socket import gaierror
+from unittest import expectedFailure
 
 from oslo_log import log as logging
 from tempest import config
@@ -138,6 +139,7 @@
             LOG.info('Function "_query_nameserver" failed with:{} '.format(e))
         return query_succeeded
 
+    @expectedFailure
     @decorators.idempotent_id('ca250d92-8a2b-11eb-b49b-74e5f9e2a801')
     def test_manually_trigger_update_secondary_zone_negative(self):
         # Create a PRIMARY zone