Merge "Fix tests for snapshots extended_snapshot_attributes policy"
diff --git a/patrole_tempest_plugin/tests/api/volume/test_snapshots_metadata_rbac.py b/patrole_tempest_plugin/tests/api/volume/test_snapshots_metadata_rbac.py
index 226411f..1c5fb2e 100644
--- a/patrole_tempest_plugin/tests/api/volume/test_snapshots_metadata_rbac.py
+++ b/patrole_tempest_plugin/tests/api/volume/test_snapshots_metadata_rbac.py
@@ -47,15 +47,6 @@
         self.snapshots_client.create_snapshot_metadata(
             self.snapshot_id, metadata)['metadata']
 
-    @rbac_rule_validation.action(
-        service="cinder",
-        rule="volume_extension:extended_snapshot_attributes")
-    @decorators.idempotent_id('c9cbec1c-edfe-46b8-825b-7b6ac0a58c25')
-    def test_create_snapshot_metadata(self):
-        # Create metadata for the snapshot
-        with self.rbac_utils.override_role(self):
-            self._create_test_snapshot_metadata()
-
     @rbac_rule_validation.action(service="cinder",
                                  rule="volume:get_snapshot_metadata")
     @decorators.idempotent_id('f6912bb1-62e6-483d-bcd0-e98c1641f4c3')
diff --git a/patrole_tempest_plugin/tests/api/volume/test_volumes_snapshots_rbac.py b/patrole_tempest_plugin/tests/api/volume/test_volumes_snapshots_rbac.py
index 5553292..7d721c4 100644
--- a/patrole_tempest_plugin/tests/api/volume/test_volumes_snapshots_rbac.py
+++ b/patrole_tempest_plugin/tests/api/volume/test_volumes_snapshots_rbac.py
@@ -17,6 +17,7 @@
 from tempest import config
 from tempest.lib import decorators
 
+from patrole_tempest_plugin import rbac_exceptions
 from patrole_tempest_plugin import rbac_rule_validation
 from patrole_tempest_plugin.tests.api.volume import rbac_base
 
@@ -39,20 +40,15 @@
         # Create a test shared snapshot for tests
         cls.snapshot = cls.create_snapshot(cls.volume['id'])
 
-    def _list_by_param_values(self, params, with_detail=False):
-        # Perform list or list_details action with given params
-        # and validates result.
-        if with_detail:
-            self.snapshots_client.list_snapshots(
-                detail=True, params=params)['snapshots']
-        else:
-            self.snapshots_client.list_snapshots(
-                params=params)['snapshots']
+    def _list_by_param_values(self, with_detail=False, **params):
+        # Perform list or list_details action with given params.
+        return self.snapshots_client.list_snapshots(
+            detail=with_detail, **params)['snapshots']
 
     @rbac_rule_validation.action(service="cinder",
                                  rule="volume:create_snapshot")
     @decorators.idempotent_id('ac7b2ee5-fbc0-4360-afc2-de8fa4881ede')
-    def test_snapshot_create(self):
+    def test_create_snapshot(self):
         # Create a temp snapshot
         with self.rbac_utils.override_role(self):
             self.create_snapshot(self.volume['id'])
@@ -60,16 +56,33 @@
     @rbac_rule_validation.action(service="cinder",
                                  rule="volume:get_snapshot")
     @decorators.idempotent_id('93a11b40-1ba8-44d6-a196-f8d97220f796')
-    def test_snapshot_get(self):
+    def test_show_snapshot(self):
         # Get the snapshot
         with self.rbac_utils.override_role(self):
             self.snapshots_client.show_snapshot(
                 self.snapshot['id'])['snapshot']
 
+    @decorators.idempotent_id('5d6f5f21-9293-4f2a-8f44-cabdc24d92cb')
+    @rbac_rule_validation.action(
+        service="cinder",
+        rule="volume_extension:extended_snapshot_attributes")
+    def test_show_snapshot_with_extended_attributes(self):
+        """List snapshots with extended attributes."""
+        expected_attrs = ('os-extended-snapshot-attributes:project_id',
+                          'os-extended-snapshot-attributes:progress')
+
+        with self.rbac_utils.override_role(self):
+            resp = self.snapshots_client.show_snapshot(
+                self.snapshot['id'])['snapshot']
+        for expected_attr in expected_attrs:
+            if expected_attr not in resp:
+                raise rbac_exceptions.RbacMalformedResponse(
+                    attribute=expected_attr)
+
     @rbac_rule_validation.action(service="cinder",
                                  rule="volume:update_snapshot")
     @decorators.idempotent_id('53fe8ee3-3bea-4ae8-a979-3c98ea72f620')
-    def test_snapshot_update(self):
+    def test_update_snapshot(self):
         new_desc = 'This is the new description of snapshot.'
         params = {'description': new_desc}
         # Updates snapshot with new values
@@ -82,7 +95,7 @@
     @rbac_rule_validation.action(service="cinder",
                                  rule="volume:delete_snapshot")
     @decorators.idempotent_id('c7fe54ec-3b70-4772-ba11-f166d95888a3')
-    def test_snapshot_delete(self):
+    def test_delete_snapshot(self):
         # Create a temp snapshot
         temp_snapshot = self.create_snapshot(self.volume['id'])
         with self.rbac_utils.override_role(self):
@@ -96,17 +109,32 @@
     @decorators.idempotent_id('e4edf0c0-2cd3-420f-b8ab-4d98a0718608')
     def test_list_snapshots(self):
         """List snapshots with params."""
-        # Verify list snapshots by display_name filter
         params = {'name': self.snapshot['name']}
         with self.rbac_utils.override_role(self):
-            self._list_by_param_values(params)
+            self._list_by_param_values(**params)
 
     @decorators.idempotent_id('f3155d8e-45ee-45c9-910d-18c0242229e1')
     @rbac_rule_validation.action(service="cinder",
                                  rule="volume:get_all_snapshots")
     def test_list_snapshots_details(self):
         """List snapshots details with params."""
-        # Verify list snapshots by display_name filter
         params = {'name': self.snapshot['name']}
         with self.rbac_utils.override_role(self):
-            self._list_by_param_values(params, with_detail=True)
+            self._list_by_param_values(with_detail=True, **params)
+
+    @decorators.idempotent_id('dd37f388-2731-446d-a78f-676997ebb04a')
+    @rbac_rule_validation.action(
+        service="cinder",
+        rule="volume_extension:extended_snapshot_attributes")
+    def test_list_snapshots_details_with_extended_attributes(self):
+        """List snapshots details with extended attributes."""
+        expected_attrs = ('os-extended-snapshot-attributes:project_id',
+                          'os-extended-snapshot-attributes:progress')
+        params = {'name': self.snapshot['name']}
+
+        with self.rbac_utils.override_role(self):
+            resp = self._list_by_param_values(with_detail=True, **params)
+        for expected_attr in expected_attrs:
+            if expected_attr not in resp[0]:
+                raise rbac_exceptions.RbacMalformedResponse(
+                    attribute=expected_attr)