Policy update for volume v2 qos-specs RBAC tests

Now that Cinder has added policy granularity to qos-specs API [0],
some of the policies in the qos-specs RBAC tests are incorrect.
Policy actions that are named volume_extension:qos_specs_manage:read
need to be changed to volume_extension:qos_specs_manage:get
and volume_extension:qos_specs_manage:get_all (for show and list)
actions respectively.

[0] I1ca996e968a273b989bea0bf3c54b47349ca47fe

Change-Id: I5b732e514f626b3d77bedb721ec24e98b59116e9
Depends-On: I1ca996e968a273b989bea0bf3c54b47349ca47fe
diff --git a/patrole_tempest_plugin/tests/api/volume/test_qos_rbac.py b/patrole_tempest_plugin/tests/api/volume/test_qos_rbac.py
index 8118bca..c6703b0 100644
--- a/patrole_tempest_plugin/tests/api/volume/test_qos_rbac.py
+++ b/patrole_tempest_plugin/tests/api/volume/test_qos_rbac.py
@@ -1,4 +1,4 @@
-# Copyright 2017 AT&T Corp
+# Copyright 2017 AT&T Corporation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -28,9 +28,9 @@
         super(VolumeQOSRbacTest, cls).setup_clients()
         cls.auth_provider = cls.os_primary.auth_provider
         cls.qos_client = cls.os_primary.volume_qos_v2_client
+        cls.admin_qos_client = cls.os_admin.volume_qos_v2_client
 
     def _create_test_qos_specs(self, name=None, consumer=None, **kwargs):
-        """Create a test Qos-Specs."""
         name = name or data_utils.rand_name(self.__class__.__name__ + '-QoS')
         consumer = consumer or 'front-end'
         qos_specs = self.qos_client.create_qos(
@@ -44,122 +44,103 @@
     @decorators.idempotent_id('4f9f45f0-b379-4577-a279-cec3e917cbec')
     def test_create_qos_with_consumer(self):
         self.rbac_utils.switch_role(self, toggle_rbac_role=True)
-        # Create a qos
         self._create_test_qos_specs()
 
     @rbac_rule_validation.action(
         service="cinder", rule="volume_extension:qos_specs_manage:delete")
     @decorators.idempotent_id('fbc8a77e-6b6d-45ae-bebe-c496eb8f06f7')
     def test_delete_qos_with_consumer(self):
-        # Create a qos
         qos = self._create_test_qos_specs()
         self.rbac_utils.switch_role(self, toggle_rbac_role=True)
-        # Delete a qos
         self.qos_client.delete_qos(qos['id'])
 
     @rbac_rule_validation.action(service="cinder",
-                                 rule="volume_extension:qos_specs_manage:read")
+                                 rule="volume_extension:qos_specs_manage:get")
     @decorators.idempotent_id('22aff0dd-0343-408d-ae80-e77551956e14')
-    def test_get_qos(self):
-        # Create a qos
+    def test_show_qos(self):
         qos = self._create_test_qos_specs()
         self.rbac_utils.switch_role(self, toggle_rbac_role=True)
-        # Get a qos
         self.qos_client.show_qos(qos['id'])['qos_specs']
 
     @rbac_rule_validation.action(service="cinder",
-                                 rule="volume_extension:qos_specs_manage:read")
+                                 rule="volume_extension:qos_specs_manage:get")
+    @decorators.idempotent_id('ff1e98f3-d456-40a9-96d4-c7e4a55dcffa')
+    def test_get_association_qos(self):
+        qos = self._create_test_qos_specs()
+        vol_type = self.create_volume_type()['id']
+        self.qos_client.associate_qos(qos['id'], vol_type)
+        self.addCleanup(self.qos_client.disassociate_qos, qos['id'], vol_type)
+
+        self.rbac_utils.switch_role(self, toggle_rbac_role=True)
+        self.qos_client.show_association_qos(qos['id'])
+
+    @rbac_rule_validation.action(
+        service="cinder",
+        rule="volume_extension:qos_specs_manage:get_all")
     @decorators.idempotent_id('546b8bb1-04a4-4387-9506-a538a7f3cd6a')
     def test_list_qos(self):
         self.rbac_utils.switch_role(self, toggle_rbac_role=True)
-        # list all qos
         self.qos_client.list_qos()['qos_specs']
 
     @rbac_rule_validation.action(
         service="cinder", rule="volume_extension:qos_specs_manage:update")
     @decorators.idempotent_id('89b630b7-c170-47c3-ac80-50ed425c2d98')
     def test_set_qos_key(self):
-        # Create a qos
         qos = self._create_test_qos_specs()
         self.rbac_utils.switch_role(self, toggle_rbac_role=True)
-        # set key
         self.qos_client.set_qos_key(qos['id'], iops_bytes='500')['qos_specs']
 
     @rbac_rule_validation.action(
         service="cinder", rule="volume_extension:qos_specs_manage:update")
     @decorators.idempotent_id('6c50c837-de77-4dae-a2ec-30e05c62969c')
     def test_unset_qos_key(self):
-        # Create a qos
         qos = self._create_test_qos_specs()
-        # Set key
         self.qos_client.set_qos_key(qos['id'], iops_bytes='500')['qos_specs']
+
         self.rbac_utils.switch_role(self, toggle_rbac_role=True)
-        # Unset key
-        keys = ['iops_bytes']
-        self.qos_client.unset_qos_key(qos['id'], keys)
-        operation = 'qos-key-unset'
-        waiters.wait_for_qos_operations(self.os_admin.qos_client, qos['id'],
-                                        operation, args=keys)
+        self.qos_client.unset_qos_key(qos['id'], ['iops_bytes'])
+        waiters.wait_for_qos_operations(self.admin_qos_client, qos['id'],
+                                        'qos-key-unset', args=['iops_bytes'])
 
     @rbac_rule_validation.action(
         service="cinder", rule="volume_extension:qos_specs_manage:update")
     @decorators.idempotent_id('2047b347-8bbe-405e-bf5a-c75a0d7e3930')
     def test_associate_qos(self):
-        # Create a qos
         qos = self._create_test_qos_specs()
-        # create a test volume-type
         vol_type = self.create_volume_type()['id']
-        self.rbac_utils.switch_role(self, toggle_rbac_role=True)
-        # associate the qos-specs with volume-types
-        self.qos_client.associate_qos(qos['id'], vol_type)
-        self.addCleanup(self.qos_client.disassociate_qos, qos['id'], vol_type)
 
-    @rbac_rule_validation.action(service="cinder",
-                                 rule="volume_extension:qos_specs_manage:read")
-    @decorators.idempotent_id('ff1e98f3-d456-40a9-96d4-c7e4a55dcffa')
-    def test_get_association_qos(self):
-        # create a test volume-type
-        qos = self._create_test_qos_specs()
-        vol_type = self.create_volume_type()['id']
-        # associate the qos-specs with volume-types
-        self.qos_client.associate_qos(qos['id'], vol_type)
-        self.addCleanup(self.qos_client.disassociate_qos, qos['id'], vol_type)
         self.rbac_utils.switch_role(self, toggle_rbac_role=True)
-        # get the association of the qos-specs
-        self.qos_client.show_association_qos(qos['id'])
+        self.qos_client.associate_qos(qos['id'], vol_type)
+        self.addCleanup(
+            test_utils.call_and_ignore_notfound_exc,
+            self.qos_client.disassociate_qos, qos['id'], vol_type)
 
     @rbac_rule_validation.action(
         service="cinder", rule="volume_extension:qos_specs_manage:update")
     @decorators.idempotent_id('f12aeca1-0c02-4f33-b805-014171e5b2d4')
     def test_disassociate_qos(self):
-        # create a test volume-type
         qos = self._create_test_qos_specs()
         vol_type = self.create_volume_type()['id']
-        # associate the qos-specs with volume-types
         self.qos_client.associate_qos(qos['id'], vol_type)
         self.addCleanup(test_utils.call_and_ignore_notfound_exc,
                         self.qos_client.disassociate_qos, qos['id'], vol_type)
+
         self.rbac_utils.switch_role(self, toggle_rbac_role=True)
-        # disassociate a volume-type with qos-specs
         self.qos_client.disassociate_qos(qos['id'], vol_type)
-        operation = 'disassociate'
-        waiters.wait_for_qos_operations(self.os_admin.qos_client, qos['id'],
-                                        operation, args=vol_type)
+        waiters.wait_for_qos_operations(self.admin_qos_client, qos['id'],
+                                        'disassociate', args=vol_type)
 
     @rbac_rule_validation.action(
         service="cinder", rule="volume_extension:qos_specs_manage:update")
     @decorators.idempotent_id('9f6e664d-a5d9-4e71-b122-73a3086be1b9')
     def test_disassociate_all_qos(self):
         qos = self._create_test_qos_specs()
-        # create a test volume-type
         vol_type = self.create_volume_type()['id']
-        # associate the qos-specs with volume-types
         self.qos_client.associate_qos(qos['id'], vol_type)
         self.addCleanup(test_utils.call_and_ignore_notfound_exc,
                         self.qos_client.disassociate_qos, qos['id'], vol_type)
+
         self.rbac_utils.switch_role(self, toggle_rbac_role=True)
-        # disassociate all volume-types from qos-specs
         self.qos_client.disassociate_all_qos(qos['id'])
-        operation = 'disassociate-all'
-        waiters.wait_for_qos_operations(self.os_admin.qos_client, qos['id'],
-                                        operation)
+        waiters.wait_for_qos_operations(self.admin_qos_client, qos['id'],
+                                        'disassociate-all')