Merge "Non-admin user can perform 'extra-specs-list'"
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 da72ffc..3387a4f 100644
--- a/manila_tempest_tests/services/share/v2/json/shares_client.py
+++ b/manila_tempest_tests/services/share/v2/json/shares_client.py
@@ -220,8 +220,15 @@
         """Get detailed list of shares w/o filters."""
         return self.list_shares(detailed=True, params=params, version=version)
 
-    def get_share(self, share_id, version=LATEST_MICROVERSION):
-        resp, body = self.get("shares/%s" % share_id, version=version)
+    def get_share(self, share_id, version=LATEST_MICROVERSION,
+                  experimental=False):
+        headers = None
+        extra_headers = False
+        if experimental:
+            headers = EXPERIMENTAL
+            extra_headers = True
+        resp, body = self.get("shares/%s" % share_id, version=version,
+                              headers=headers, extra_headers=extra_headers)
         self.expected_success(200, resp.status)
         return self._parse_resp(body)
 
@@ -493,12 +500,12 @@
 
     def wait_for_migration_completed(self, share_id, dest_host):
         """Waits for a share to migrate to a certain host."""
-        share = self.get_share(share_id)
+        share = self.get_share(share_id, "2.5", True)
         migration_timeout = CONF.share.migration_timeout
         start = int(time.time())
         while share['task_state'] != 'migration_success':
             time.sleep(self.build_interval)
-            share = self.get_share(share_id)
+            share = self.get_share(share_id, "2.5", True)
             if share['task_state'] == 'migration_success':
                 return share
             elif share['task_state'] == 'migration_error':
diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py
index 591347e..825b6e0 100644
--- a/manila_tempest_tests/tests/api/base.py
+++ b/manila_tempest_tests/tests/api/base.py
@@ -288,7 +288,7 @@
                       share_network_id=None, share_type_id=None,
                       consistency_group_id=None, client=None,
                       cleanup_in_class=True, is_public=False, **kwargs):
-        client = client or cls.shares_client
+        client = client or cls.shares_v2_client
         description = description or "Tempest's share"
         share_network_id = share_network_id or client.share_network_id or None
         metadata = metadata or {}
@@ -358,7 +358,7 @@
                     "Expected only 'args' and 'kwargs' keys. "
                     "Provided %s" % list(d))
             d["kwargs"]["client"] = d["kwargs"].get(
-                "client", cls.shares_client)
+                "client", cls.shares_v2_client)
             d["share"] = cls._create_share(*d["args"], **d["kwargs"])
             d["cnt"] = 0
             d["available"] = False
diff --git a/manila_tempest_tests/tests/api/test_shares.py b/manila_tempest_tests/tests/api/test_shares.py
index b5c7e01..27ce1c0 100644
--- a/manila_tempest_tests/tests/api/test_shares.py
+++ b/manila_tempest_tests/tests/api/test_shares.py
@@ -13,6 +13,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import six
 from tempest import config  # noqa
 from tempest import test  # noqa
 from tempest_lib import exceptions as lib_exc  # noqa
@@ -35,17 +36,19 @@
             raise cls.skipException(message)
         cls.share = cls.create_share(cls.protocol)
 
-    @test.attr(type=["gate", ])
-    def test_create_delete_share(self):
+    def _create_delete_share(self, version):
 
         # create share
-        share = self.create_share(self.protocol)
+        share = self.create_share(
+            self.protocol, version=six.text_type(version))
         detailed_elements = {'name', 'id', 'availability_zone',
                              'description', 'export_location', 'project_id',
                              'host', 'created_at', 'share_proto', 'metadata',
                              'size', 'snapshot_id', 'share_network_id',
                              'status', 'share_type', 'volume_type', 'links',
                              'is_public'}
+        if version > 2.2:
+            detailed_elements.add('snapshot_support')
         self.assertTrue(detailed_elements.issubset(share.keys()),
                         'At least one expected element missing from share '
                         'response. Expected %(expected)s, got %(actual)s.' % {
@@ -61,6 +64,14 @@
                           share['id'])
 
     @test.attr(type=["gate", ])
+    def test_create_delete_share_without_snapshot_support_feature(self):
+        self._create_delete_share(2.1)
+
+    @test.attr(type=["gate", ])
+    def test_create_delete_share_with_snapshot_support_feature(self):
+        self._create_delete_share(2.2)
+
+    @test.attr(type=["gate", ])
     @testtools.skipUnless(CONF.share.run_snapshot_tests,
                           "Snapshot tests are disabled.")
     def test_create_delete_snapshot(self):
diff --git a/manila_tempest_tests/tests/api/test_shares_actions.py b/manila_tempest_tests/tests/api/test_shares_actions.py
index 94754a8..58ddbfe 100644
--- a/manila_tempest_tests/tests/api/test_shares_actions.py
+++ b/manila_tempest_tests/tests/api/test_shares_actions.py
@@ -13,6 +13,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import six
 from tempest import config  # noqa
 from tempest import test  # noqa
 from tempest_lib.common.utils import data_utils  # noqa
@@ -71,34 +72,45 @@
                 snapshot_id=cls.snap['id'],
             ))
 
-    @test.attr(type=["gate", ])
-    def test_get_share(self):
+    def _get_share(self, version):
 
         # get share
-        share = self.shares_client.get_share(self.shares[0]['id'])
+        share = self.shares_v2_client.get_share(
+            self.shares[0]['id'], version=six.text_type(version))
 
         # verify keys
         expected_keys = ["status", "description", "links", "availability_zone",
                          "created_at", "export_location", "share_proto",
                          "name", "snapshot_id", "id", "size"]
-        actual_keys = share.keys()
+        if version > 2.1:
+            expected_keys.append("snapshot_support")
+        actual_keys = list(share.keys())
         [self.assertIn(key, actual_keys) for key in expected_keys]
 
         # verify values
         msg = "Expected name: '%s', actual name: '%s'" % (self.share_name,
                                                           share["name"])
-        self.assertEqual(self.share_name, str(share["name"]), msg)
+        self.assertEqual(self.share_name, six.text_type(share["name"]), msg)
 
         msg = "Expected description: '%s', "\
               "actual description: '%s'" % (self.share_desc,
                                             share["description"])
-        self.assertEqual(self.share_desc, str(share["description"]), msg)
+        self.assertEqual(
+            self.share_desc, six.text_type(share["description"]), msg)
 
         msg = "Expected size: '%s', actual size: '%s'" % (self.share_size,
                                                           share["size"])
         self.assertEqual(self.share_size, int(share["size"]), msg)
 
     @test.attr(type=["gate", ])
+    def test_get_share_no_snapshot_support_key(self):
+        self._get_share(2.1)
+
+    @test.attr(type=["gate", ])
+    def test_get_share_with_snapshot_support_key(self):
+        self._get_share(2.2)
+
+    @test.attr(type=["gate", ])
     def test_list_shares(self):
 
         # list shares
@@ -114,11 +126,11 @@
             msg = "expected id lists %s times in share list" % (len(gen))
             self.assertEqual(1, len(gen), msg)
 
-    @test.attr(type=["gate", ])
-    def test_list_shares_with_detail(self):
+    def _list_shares_with_detail(self, version):
 
         # list shares
-        shares = self.shares_client.list_shares_with_detail()
+        shares = self.shares_v2_client.list_shares_with_detail(
+            version=six.text_type(version))
 
         # verify keys
         keys = [
@@ -126,6 +138,8 @@
             "created_at", "export_location", "share_proto", "host",
             "name", "snapshot_id", "id", "size", "project_id",
         ]
+        if version > 2.1:
+            keys.append("snapshot_support")
         [self.assertIn(key, sh.keys()) for sh in shares for key in keys]
 
         # our shares in list and have no duplicates
@@ -135,6 +149,14 @@
             self.assertEqual(1, len(gen), msg)
 
     @test.attr(type=["gate", ])
+    def test_list_shares_with_detail_without_snapshot_support_key(self):
+        self._list_shares_with_detail(2.1)
+
+    @test.attr(type=["gate", ])
+    def test_list_shares_with_detail_and_snapshot_support_key(self):
+        self._list_shares_with_detail(2.2)
+
+    @test.attr(type=["gate", ])
     def test_list_shares_with_detail_filter_by_metadata(self):
         filters = {'metadata': self.metadata}