Merge "Fix access rules tempest v2 client"
diff --git a/manila_tempest_tests/services/share/v2/json/shares_client.py b/manila_tempest_tests/services/share/v2/json/shares_client.py
index 806f108..ff062bf 100644
--- a/manila_tempest_tests/services/share/v2/json/shares_client.py
+++ b/manila_tempest_tests/services/share/v2/json/shares_client.py
@@ -377,16 +377,16 @@
 
 ###############
 
-    def _get_access_action_name(self, version):
+    def _get_access_action_name(self, version, action):
         if utils.is_microversion_gt(version, "2.6"):
-            return 'allow_access'
-        return 'os-allow_access'
+            return action.split('os-')[-1]
+        return action
 
     def create_access_rule(self, share_id, access_type="ip",
                            access_to="0.0.0.0", access_level=None,
                            version=LATEST_MICROVERSION, action_name=None):
         post_body = {
-            self._get_access_action_name(version): {
+            self._get_access_action_name(version, 'os-allow_access'): {
                 "access_type": access_type,
                 "access_to": access_to,
                 "access_level": access_level,
@@ -400,7 +400,7 @@
 
     def list_access_rules(self, share_id, version=LATEST_MICROVERSION,
                           action_name=None):
-        body = {self._get_access_action_name(version): None}
+        body = {self._get_access_action_name(version, 'os-access_list'): None}
         resp, body = self.post(
             "shares/%s/action" % share_id, json.dumps(body), version=version)
         self.expected_success(200, resp.status)
@@ -409,7 +409,7 @@
     def delete_access_rule(self, share_id, rule_id,
                            version=LATEST_MICROVERSION, action_name=None):
         post_body = {
-            self._get_access_action_name(version): {
+            self._get_access_action_name(version, 'os-deny_access'): {
                 "access_id": rule_id,
             }
         }
diff --git a/manila_tempest_tests/tests/api/test_rules.py b/manila_tempest_tests/tests/api/test_rules.py
index 0399d27..6f323d9 100644
--- a/manila_tempest_tests/tests/api/test_rules.py
+++ b/manila_tempest_tests/tests/api/test_rules.py
@@ -13,6 +13,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import ddt
 from tempest import config  # noqa
 from tempest import test  # noqa
 from tempest_lib import exceptions as lib_exc  # noqa
@@ -23,24 +24,25 @@
 CONF = config.CONF
 
 
-def _create_delete_ro_access_rule(self):
+def _create_delete_ro_access_rule(self, client_name):
     """Common test case for usage in test suites with different decorators.
 
     :param self: instance of test class
     """
-    rule = self.shares_client.create_access_rule(
+    rule = getattr(self, client_name).create_access_rule(
         self.share["id"], self.access_type, self.access_to, 'ro')
 
     self.assertEqual('ro', rule['access_level'])
     for key in ('deleted', 'deleted_at', 'instance_mappings'):
         self.assertNotIn(key, rule.keys())
-    self.shares_client.wait_for_access_rule_status(
+    getattr(self, client_name).wait_for_access_rule_status(
         self.share["id"], rule["id"], "active")
-    self.shares_client.delete_access_rule(self.share["id"], rule["id"])
-    self.shares_client.wait_for_resource_deletion(
+    getattr(self, client_name).delete_access_rule(self.share["id"], rule["id"])
+    getattr(self, client_name).wait_for_resource_deletion(
         rule_id=rule["id"], share_id=self.share['id'])
 
 
+@ddt.ddt
 class ShareIpRulesForNFSTest(base.BaseSharesTest):
     protocol = "nfs"
 
@@ -56,55 +58,61 @@
         cls.access_to = "2.2.2.2"
 
     @test.attr(type=["gate", ])
-    def test_create_delete_access_rules_with_one_ip(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_delete_access_rules_with_one_ip(self, client_name):
 
         # test data
         access_to = "1.1.1.1"
 
         # create rule
-        rule = self.shares_client.create_access_rule(
+        rule = getattr(self, client_name).create_access_rule(
             self.share["id"], self.access_type, access_to)
 
         self.assertEqual('rw', rule['access_level'])
         for key in ('deleted', 'deleted_at', 'instance_mappings'):
             self.assertNotIn(key, rule.keys())
-        self.shares_client.wait_for_access_rule_status(
+        getattr(self, client_name).wait_for_access_rule_status(
             self.share["id"], rule["id"], "active")
 
         # delete rule and wait for deletion
-        self.shares_client.delete_access_rule(self.share["id"], rule["id"])
-        self.shares_client.wait_for_resource_deletion(
+        getattr(self, client_name).delete_access_rule(self.share["id"],
+                                                      rule["id"])
+        getattr(self, client_name).wait_for_resource_deletion(
             rule_id=rule["id"], share_id=self.share['id'])
 
     @test.attr(type=["gate", ])
-    def test_create_delete_access_rule_with_cidr(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_delete_access_rule_with_cidr(self, client_name):
 
         # test data
         access_to = "1.2.3.4/32"
 
         # create rule
-        rule = self.shares_client.create_access_rule(
+        rule = getattr(self, client_name).create_access_rule(
             self.share["id"], self.access_type, access_to)
 
         for key in ('deleted', 'deleted_at', 'instance_mappings'):
             self.assertNotIn(key, rule.keys())
         self.assertEqual('rw', rule['access_level'])
-        self.shares_client.wait_for_access_rule_status(
+        getattr(self, client_name).wait_for_access_rule_status(
             self.share["id"], rule["id"], "active")
 
         # delete rule and wait for deletion
-        self.shares_client.delete_access_rule(self.share["id"], rule["id"])
-        self.shares_client.wait_for_resource_deletion(
+        getattr(self, client_name).delete_access_rule(self.share["id"],
+                                                      rule["id"])
+        getattr(self, client_name).wait_for_resource_deletion(
             rule_id=rule["id"], share_id=self.share['id'])
 
     @test.attr(type=["gate", ])
     @testtools.skipIf(
         "nfs" not in CONF.share.enable_ro_access_level_for_protocols,
         "RO access rule tests are disabled for NFS protocol.")
-    def test_create_delete_ro_access_rule(self):
-        _create_delete_ro_access_rule(self)
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_delete_ro_access_rule(self, client_name):
+        _create_delete_ro_access_rule(self, client_name)
 
 
+@ddt.ddt
 class ShareIpRulesForCIFSTest(ShareIpRulesForNFSTest):
     protocol = "cifs"
 
@@ -112,10 +120,12 @@
     @testtools.skipIf(
         "cifs" not in CONF.share.enable_ro_access_level_for_protocols,
         "RO access rule tests are disabled for CIFS protocol.")
-    def test_create_delete_ro_access_rule(self):
-        _create_delete_ro_access_rule(self)
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_delete_ro_access_rule(self, client_name):
+        _create_delete_ro_access_rule(self, client_name)
 
 
+@ddt.ddt
 class ShareUserRulesForNFSTest(base.BaseSharesTest):
     protocol = "nfs"
 
@@ -132,31 +142,35 @@
         cls.access_to = CONF.share.username_for_user_rules
 
     @test.attr(type=["gate", ])
-    def test_create_delete_user_rule(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_delete_user_rule(self, client_name):
 
         # create rule
-        rule = self.shares_client.create_access_rule(
+        rule = getattr(self, client_name).create_access_rule(
             self.share["id"], self.access_type, self.access_to)
 
         self.assertEqual('rw', rule['access_level'])
         for key in ('deleted', 'deleted_at', 'instance_mappings'):
             self.assertNotIn(key, rule.keys())
-        self.shares_client.wait_for_access_rule_status(
+        getattr(self, client_name).wait_for_access_rule_status(
             self.share["id"], rule["id"], "active")
 
         # delete rule and wait for deletion
-        self.shares_client.delete_access_rule(self.share["id"], rule["id"])
-        self.shares_client.wait_for_resource_deletion(
+        getattr(self, client_name).delete_access_rule(self.share["id"],
+                                                      rule["id"])
+        getattr(self, client_name).wait_for_resource_deletion(
             rule_id=rule["id"], share_id=self.share['id'])
 
     @test.attr(type=["gate", ])
     @testtools.skipIf(
         "nfs" not in CONF.share.enable_ro_access_level_for_protocols,
         "RO access rule tests are disabled for NFS protocol.")
-    def test_create_delete_ro_access_rule(self):
-        _create_delete_ro_access_rule(self)
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_delete_ro_access_rule(self, client_name):
+        _create_delete_ro_access_rule(self, client_name)
 
 
+@ddt.ddt
 class ShareUserRulesForCIFSTest(ShareUserRulesForNFSTest):
     protocol = "cifs"
 
@@ -164,10 +178,12 @@
     @testtools.skipIf(
         "cifs" not in CONF.share.enable_ro_access_level_for_protocols,
         "RO access rule tests are disabled for CIFS protocol.")
-    def test_create_delete_ro_access_rule(self):
-        _create_delete_ro_access_rule(self)
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_delete_ro_access_rule(self, client_name):
+        _create_delete_ro_access_rule(self, client_name)
 
 
+@ddt.ddt
 class ShareCertRulesForGLUSTERFSTest(base.BaseSharesTest):
     protocol = "glusterfs"
 
@@ -186,37 +202,42 @@
         cls.access_to = "client1.com"
 
     @test.attr(type=["gate", ])
-    def test_create_delete_cert_rule(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_delete_cert_rule(self, client_name):
 
         # create rule
-        rule = self.shares_client.create_access_rule(
+        rule = getattr(self, client_name).create_access_rule(
             self.share["id"], self.access_type, self.access_to)
 
         self.assertEqual('rw', rule['access_level'])
         for key in ('deleted', 'deleted_at', 'instance_mappings'):
             self.assertNotIn(key, rule.keys())
-        self.shares_client.wait_for_access_rule_status(
+        getattr(self, client_name).wait_for_access_rule_status(
             self.share["id"], rule["id"], "active")
 
         # delete rule
-        self.shares_client.delete_access_rule(self.share["id"], rule["id"])
+        getattr(self, client_name).delete_access_rule(self.share["id"],
+                                                      rule["id"])
 
     @test.attr(type=["gate", ])
     @testtools.skipIf(
         "glusterfs" not in CONF.share.enable_ro_access_level_for_protocols,
         "RO access rule tests are disabled for GLUSTERFS protocol.")
-    def test_create_delete_cert_ro_access_rule(self):
-        rule = self.shares_client.create_access_rule(
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_delete_cert_ro_access_rule(self, client_name):
+        rule = getattr(self, client_name).create_access_rule(
             self.share["id"], 'cert', 'client2.com', 'ro')
 
         self.assertEqual('ro', rule['access_level'])
         for key in ('deleted', 'deleted_at', 'instance_mappings'):
             self.assertNotIn(key, rule.keys())
-        self.shares_client.wait_for_access_rule_status(
+        getattr(self, client_name).wait_for_access_rule_status(
             self.share["id"], rule["id"], "active")
-        self.shares_client.delete_access_rule(self.share["id"], rule["id"])
+        getattr(self, client_name).delete_access_rule(self.share["id"],
+                                                      rule["id"])
 
 
+@ddt.ddt
 class ShareRulesTest(base.BaseSharesTest):
 
     @classmethod
@@ -246,17 +267,18 @@
         cls.share = cls.create_share()
 
     @test.attr(type=["gate", ])
-    def test_list_access_rules(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_list_access_rules(self, client_name):
 
         # create rule
-        rule = self.shares_client.create_access_rule(
+        rule = getattr(self, client_name).create_access_rule(
             self.share["id"], self.access_type, self.access_to)
 
-        self.shares_client.wait_for_access_rule_status(
+        getattr(self, client_name).wait_for_access_rule_status(
             self.share["id"], rule["id"], "active")
 
         # list rules
-        rules = self.shares_client.list_access_rules(self.share["id"])
+        rules = getattr(self, client_name).list_access_rules(self.share["id"])
 
         # verify keys
         for key in ("state", "id", "access_type", "access_to", "access_level"):
@@ -275,23 +297,31 @@
         msg = "expected id lists %s times in rule list" % (len(gen))
         self.assertEqual(len(gen), 1, msg)
 
+        getattr(self, client_name).delete_access_rule(
+            self.share['id'], rule['id'])
+
+        getattr(self, client_name).wait_for_resource_deletion(
+            rule_id=rule["id"], share_id=self.share['id'])
+
     @test.attr(type=["gate", ])
-    def test_access_rules_deleted_if_share_deleted(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_access_rules_deleted_if_share_deleted(self, client_name):
 
         # create share
         share = self.create_share()
 
         # create rule
-        rule = self.shares_client.create_access_rule(
+        rule = getattr(self, client_name).create_access_rule(
             share["id"], self.access_type, self.access_to)
-        self.shares_client.wait_for_access_rule_status(
+        getattr(self, client_name).wait_for_access_rule_status(
             share["id"], rule["id"], "active")
 
         # delete share
-        self.shares_client.delete_share(share['id'])
-        self.shares_client.wait_for_resource_deletion(share_id=share['id'])
+        getattr(self, client_name).delete_share(share['id'])
+        getattr(self, client_name).wait_for_resource_deletion(
+            share_id=share['id'])
 
         # verify absence of rules for nonexistent share id
         self.assertRaises(lib_exc.NotFound,
-                          self.shares_client.list_access_rules,
+                          getattr(self, client_name).list_access_rules,
                           share['id'])
diff --git a/manila_tempest_tests/tests/api/test_rules_negative.py b/manila_tempest_tests/tests/api/test_rules_negative.py
index 6ad36ba..71b5244 100644
--- a/manila_tempest_tests/tests/api/test_rules_negative.py
+++ b/manila_tempest_tests/tests/api/test_rules_negative.py
@@ -13,6 +13,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import ddt
 from tempest import config  # noqa
 from tempest import test  # noqa
 from tempest_lib import exceptions as lib_exc  # noqa
@@ -23,6 +24,7 @@
 CONF = config.CONF
 
 
+@ddt.ddt
 class ShareIpRulesForNFSNegativeTest(base.BaseSharesTest):
     protocol = "nfs"
 
@@ -40,84 +42,102 @@
             cls.snap = cls.create_snapshot_wait_for_active(cls.share["id"])
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_ip_with_wrong_target_1(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_ip_with_wrong_target_1(self, client_name):
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"], "ip", "1.2.3.256")
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_ip_with_wrong_target_2(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_ip_with_wrong_target_2(self, client_name):
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"], "ip", "1.1.1.-")
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_ip_with_wrong_target_3(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_ip_with_wrong_target_3(self, client_name):
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"], "ip", "1.2.3.4/33")
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_ip_with_wrong_target_4(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_ip_with_wrong_target_4(self, client_name):
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"], "ip", "1.2.3.*")
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_ip_with_wrong_target_5(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_ip_with_wrong_target_5(self, client_name):
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"], "ip", "1.2.3.*/23")
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_ip_with_wrong_target_6(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_ip_with_wrong_target_6(self, client_name):
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"], "ip", "1.2.3.1|23")
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_ip_with_wrong_target_7(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_ip_with_wrong_target_7(self, client_name):
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"], "ip", "1.2.3.1/-1")
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_ip_with_wrong_target_8(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_ip_with_wrong_target_8(self, client_name):
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"], "ip", "1.2.3.1/")
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_with_wrong_level(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_with_wrong_level(self, client_name):
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"],
                           'ip',
                           '2.2.2.2',
                           'su')
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_duplicate_of_ip_rule(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_duplicate_of_ip_rule(self, client_name):
         # test data
         access_type = "ip"
         access_to = "1.2.3.4"
 
         # create rule
-        rule = self.shares_client.create_access_rule(
+        rule = getattr(self, client_name).create_access_rule(
             self.share["id"], access_type, access_to)
-        self.shares_client.wait_for_access_rule_status(
+        getattr(self, client_name).wait_for_access_rule_status(
             self.share["id"], rule["id"], "active")
 
         # try create duplicate of rule
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"], access_type, access_to)
 
+        # delete rule and wait for deletion
+        getattr(self, client_name).delete_access_rule(self.share["id"],
+                                                      rule["id"])
+        getattr(self, client_name).wait_for_resource_deletion(
+            rule_id=rule["id"], share_id=self.share['id'])
 
+
+@ddt.ddt
 class ShareIpRulesForCIFSNegativeTest(ShareIpRulesForNFSNegativeTest):
     protocol = "cifs"
 
 
+@ddt.ddt
 class ShareUserRulesForNFSNegativeTest(base.BaseSharesTest):
     protocol = "nfs"
 
@@ -135,69 +155,79 @@
             cls.snap = cls.create_snapshot_wait_for_active(cls.share["id"])
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_user_with_wrong_input_2(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_user_with_wrong_input_2(self, client_name):
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"], "user",
                           "try+")
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_user_with_empty_key(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_user_with_empty_key(self, client_name):
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"], "user", "")
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_user_with_too_little_key(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_user_with_too_little_key(self, client_name):
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"], "user", "abc")
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_user_with_too_big_key(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_user_with_too_big_key(self, client_name):
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"], "user", "a" * 33)
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_user_with_wrong_input_1(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_user_with_wrong_input_1(self, client_name):
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"], "user",
                           "try+")
 
     @test.attr(type=["negative", "gate", ])
+    @ddt.data('shares_client', 'shares_v2_client')
     @testtools.skipUnless(CONF.share.run_snapshot_tests,
                           "Snapshot tests are disabled.")
-    def test_create_access_rule_user_to_snapshot(self):
+    def test_create_access_rule_user_to_snapshot(self, client_name):
         self.assertRaises(lib_exc.NotFound,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.snap["id"],
                           access_type="user",
                           access_to="fakeuser")
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_user_with_wrong_share_id(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_user_with_wrong_share_id(self, client_name):
         self.assertRaises(lib_exc.NotFound,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           "wrong_share_id",
                           access_type="user",
                           access_to="fakeuser")
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_with_wrong_level(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_with_wrong_level(self, client_name):
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"],
                           'user',
                           CONF.share.username_for_user_rules,
                           'su')
 
 
+@ddt.ddt
 class ShareUserRulesForCIFSNegativeTest(ShareUserRulesForNFSNegativeTest):
     protocol = "cifs"
 
 
+@ddt.ddt
 class ShareCertRulesForGLUSTERFSNegativeTest(base.BaseSharesTest):
     protocol = "glusterfs"
 
@@ -215,43 +245,51 @@
             cls.snap = cls.create_snapshot_wait_for_active(cls.share["id"])
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_cert_with_empty_common_name(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_cert_with_empty_common_name(self, client_name):
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"], "cert", "")
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_cert_with_whitespace_common_name(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_cert_with_whitespace_common_name(self,
+                                                                 client_name):
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"], "cert", " ")
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_cert_with_too_big_common_name(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_cert_with_too_big_common_name(self,
+                                                              client_name):
         # common name cannot be more than 64 characters long
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"], "cert", "a" * 65)
 
     @test.attr(type=["negative", "gate", ])
     @testtools.skipUnless(CONF.share.run_snapshot_tests,
                           "Snapshot tests are disabled.")
-    def test_create_access_rule_cert_to_snapshot(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_cert_to_snapshot(self, client_name):
         self.assertRaises(lib_exc.NotFound,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.snap["id"],
                           access_type="cert",
                           access_to="fakeclient1.com")
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_cert_with_wrong_share_id(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_cert_with_wrong_share_id(self, client_name):
         self.assertRaises(lib_exc.NotFound,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           "wrong_share_id",
                           access_type="cert",
                           access_to="fakeclient2.com")
 
 
+@ddt.ddt
 class ShareRulesNegativeTest(base.BaseSharesTest):
     # Tests independent from rule type and share protocol
 
@@ -273,27 +311,31 @@
             cls.snap = cls.create_snapshot_wait_for_active(cls.share["id"])
 
     @test.attr(type=["negative", "gate", ])
-    def test_delete_access_rule_with_wrong_id(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_delete_access_rule_with_wrong_id(self, client_name):
         self.assertRaises(lib_exc.NotFound,
-                          self.shares_client.delete_access_rule,
+                          getattr(self, client_name).delete_access_rule,
                           self.share["id"], "wrong_rule_id")
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_ip_with_wrong_type(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_ip_with_wrong_type(self, client_name):
         self.assertRaises(lib_exc.BadRequest,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.share["id"], "wrong_type", "1.2.3.4")
 
     @test.attr(type=["negative", "gate", ])
-    def test_create_access_rule_ip_with_wrong_share_id(self):
+    @ddt.data('shares_client', 'shares_v2_client')
+    def test_create_access_rule_ip_with_wrong_share_id(self, client_name):
         self.assertRaises(lib_exc.NotFound,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           "wrong_share_id")
 
     @test.attr(type=["negative", "gate", ])
+    @ddt.data('shares_client', 'shares_v2_client')
     @testtools.skipUnless(CONF.share.run_snapshot_tests,
                           "Snapshot tests are disabled.")
-    def test_create_access_rule_ip_to_snapshot(self):
+    def test_create_access_rule_ip_to_snapshot(self, client_name):
         self.assertRaises(lib_exc.NotFound,
-                          self.shares_client.create_access_rule,
+                          getattr(self, client_name).create_access_rule,
                           self.snap["id"])