Merge "Add like filter"
diff --git a/manila_tempest_tests/config.py b/manila_tempest_tests/config.py
index 062bf97..b48ac9f 100644
--- a/manila_tempest_tests/config.py
+++ b/manila_tempest_tests/config.py
@@ -30,7 +30,7 @@
                help="The minimum api microversion is configured to be the "
                     "value of the minimum microversion supported by Manila."),
     cfg.StrOpt("max_api_microversion",
-               default="2.35",
+               default="2.36",
                help="The maximum api microversion is configured to be the "
                     "value of the latest microversion supported by Manila."),
     cfg.StrOpt("region",
diff --git a/manila_tempest_tests/tests/api/test_share_group_actions.py b/manila_tempest_tests/tests/api/test_share_group_actions.py
index aa582bf..7196be8 100644
--- a/manila_tempest_tests/tests/api/test_share_group_actions.py
+++ b/manila_tempest_tests/tests/api/test_share_group_actions.py
@@ -14,6 +14,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import ddt
 from tempest import config
 from tempest.lib.common.utils import data_utils
 import testtools
@@ -21,6 +22,7 @@
 
 from manila_tempest_tests.common import constants
 from manila_tempest_tests.tests.api import base
+from manila_tempest_tests import utils
 
 CONF = config.CONF
 
@@ -28,6 +30,7 @@
 @testtools.skipUnless(
     CONF.share.run_share_group_tests, 'Share Group tests disabled.')
 @base.skip_if_microversion_lt(constants.MIN_SHARE_GROUP_MICROVERSION)
+@ddt.ddt
 class ShareGroupActionsTest(base.BaseSharesTest):
     """Covers share group functionality."""
 
@@ -157,11 +160,14 @@
             self.assertEqual(1, len(gen), msg)
 
     @tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
-    def test_list_share_groups_with_detail_min(self):
-
+    @ddt.data(constants.MIN_SHARE_GROUP_MICROVERSION, '2.36')
+    def test_list_share_groups_with_detail_min(self, version):
+        params = None
+        if utils.is_microversion_ge(version, '2.36'):
+            params = {'name~': 'tempest', 'description~': 'tempest'}
         # List share groups
         share_groups = self.shares_v2_client.list_share_groups(
-            detailed=True, version=constants.MIN_SHARE_GROUP_MICROVERSION)
+            detailed=True, params=params, version=version)
 
         # Verify keys
         for sg in share_groups:
diff --git a/manila_tempest_tests/tests/api/test_share_networks.py b/manila_tempest_tests/tests/api/test_share_networks.py
index 70f1494..bcedd5e 100644
--- a/manila_tempest_tests/tests/api/test_share_networks.py
+++ b/manila_tempest_tests/tests/api/test_share_networks.py
@@ -71,6 +71,22 @@
                                 for ss in ss_list))
 
     @tc.attr(base.TAG_POSITIVE, base.TAG_API)
+    @base.skip_if_microversion_lt("2.36")
+    def test_list_share_networks_like_filter(self):
+        valid_filter_opts = {
+            'name': 'sn_with_ldap_ss',
+            'description': 'fake',
+        }
+
+        listed = self.shares_v2_client.list_share_networks_with_detail(
+            {'name~': 'ldap_ss', 'description~': 'fa'})
+        self.assertTrue(any(self.sn_with_ldap_ss['id'] == sn['id']
+                            for sn in listed))
+        for sn in listed:
+            self.assertTrue(all(value in sn[key] for key, value in
+                                valid_filter_opts.items()))
+
+    @tc.attr(base.TAG_POSITIVE, base.TAG_API)
     def test_list_share_networks_all_filter_opts(self):
         valid_filter_opts = {
             'created_before': '2002-10-10',
diff --git a/manila_tempest_tests/tests/api/test_share_networks_negative.py b/manila_tempest_tests/tests/api/test_share_networks_negative.py
index 0ec9407..e7e3df4 100644
--- a/manila_tempest_tests/tests/api/test_share_networks_negative.py
+++ b/manila_tempest_tests/tests/api/test_share_networks_negative.py
@@ -128,3 +128,16 @@
         self.assertRaises(
             lib_exc.Conflict,
             self.shares_client.delete_share_network, new_sn['id'])
+
+    @tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
+    @base.skip_if_microversion_not_supported("2.35")
+    def test_list_shares_with_like_filter_not_exist(self):
+        filters = {
+            'name~': 'fake_not_exist',
+            'description~': 'fake_not_exist',
+        }
+        share_networks = (
+            self.shares_v2_client.list_share_networks_with_detail(
+                params=filters))
+
+        self.assertEqual(0, len(share_networks))
diff --git a/manila_tempest_tests/tests/api/test_shares_actions.py b/manila_tempest_tests/tests/api/test_shares_actions.py
index 97dd9dd..e12990e 100644
--- a/manila_tempest_tests/tests/api/test_shares_actions.py
+++ b/manila_tempest_tests/tests/api/test_shares_actions.py
@@ -337,6 +337,15 @@
         self.assertEqual(self.share_name, shares[0]["name"])
 
     @tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
+    @base.skip_if_microversion_lt("2.36")
+    def test_list_shares_with_detail_filter_by_nonexistent_name(self):
+        # list shares by name, at least one share is expected
+        params = {"name~": 'tempest-share'}
+        shares = self.shares_v2_client.list_shares_with_detail(params)
+        for share in shares:
+            self.assertIn('tempest-share', share["name"])
+
+    @tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
     def test_list_shares_with_detail_filter_by_fake_name(self):
         # list shares by fake name, no shares are expected
         params = {"name": data_utils.rand_name("fake-nonexistent-name")}
@@ -481,16 +490,18 @@
     @tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
     @testtools.skipUnless(CONF.share.run_snapshot_tests,
                           "Snapshot tests are disabled.")
-    @ddt.data(None, '2.16', LATEST_MICROVERSION)
+    @ddt.data(None, '2.16', '2.36', LATEST_MICROVERSION)
     def test_list_snapshots_with_detail(self, version):
-
+        params = None
+        if version and utils.is_microversion_ge(version, '2.36'):
+            params = {'name~': 'tempest', 'description~': 'tempest'}
         # list share snapshots
         if version is None:
             snaps = self.shares_client.list_snapshots_with_detail()
         else:
             utils.skip_if_microversion_not_supported(version)
             snaps = self.shares_v2_client.list_snapshots_with_detail(
-                version=version)
+                version=version, params=params)
 
         # verify keys
         expected_keys = ["status", "links", "share_id", "name",
diff --git a/manila_tempest_tests/tests/api/test_shares_actions_negative.py b/manila_tempest_tests/tests/api/test_shares_actions_negative.py
index 1f3258d..1f3da5f 100644
--- a/manila_tempest_tests/tests/api/test_shares_actions_negative.py
+++ b/manila_tempest_tests/tests/api/test_shares_actions_negative.py
@@ -165,3 +165,29 @@
             params=filters)
 
         self.assertEqual(0, len(shares))
+
+    @tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
+    @base.skip_if_microversion_not_supported("2.35")
+    def test_list_shares_with_like_filter_and_invalid_version(self):
+        # In API versions < v2.36, querying the share API by inexact
+        # filter (name or description) should have no effect. Those
+        # filters were supported from v2.36
+        filters = {
+            'name~': 'fake',
+            'description~': 'fake',
+        }
+        shares = self.shares_v2_client.list_shares(
+            params=filters, version="2.35")
+
+        self.assertGreater(len(shares), 0)
+
+    @tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
+    @base.skip_if_microversion_not_supported("2.35")
+    def test_list_shares_with_like_filter_not_exist(self):
+        filters = {
+            'name~': 'fake_not_exist',
+            'description~': 'fake_not_exist',
+        }
+        shares = self.shares_v2_client.list_shares(params=filters)
+
+        self.assertEqual(0, len(shares))