diff --git a/manila_tempest_tests/config.py b/manila_tempest_tests/config.py
index 4e51ad5..8cf618a 100644
--- a/manila_tempest_tests/config.py
+++ b/manila_tempest_tests/config.py
@@ -36,7 +36,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.16",
+               default="2.17",
                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/admin/test_snapshot_manage.py b/manila_tempest_tests/tests/api/admin/test_snapshot_manage.py
index 3eed886..ecdd3bd 100644
--- a/manila_tempest_tests/tests/api/admin/test_snapshot_manage.py
+++ b/manila_tempest_tests/tests/api/admin/test_snapshot_manage.py
@@ -13,6 +13,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import ddt
 import six
 from tempest import config
 from tempest.lib.common.utils import data_utils
@@ -21,10 +22,12 @@
 import testtools
 
 from manila_tempest_tests.tests.api import base
+from manila_tempest_tests import utils
 
 CONF = config.CONF
 
 
+@ddt.ddt
 class ManageNFSSnapshotTest(base.BaseSharesAdminTest):
     protocol = 'nfs'
 
@@ -59,31 +62,12 @@
             cleanup_in_class=True,
             extra_specs=cls.extra_specs)
 
-        creation_data = {'kwargs': {
-            'share_type_id': cls.st['share_type']['id'],
-            'share_protocol': cls.protocol,
-        }}
+        # Create the base share
+        cls.share = cls.create_share(share_type_id=cls.st['share_type']['id'],
+                                     share_protocol=cls.protocol)
 
-        # Data for creating shares
-        data = [creation_data]
-        shares_created = cls.create_shares(data)
-
-        cls.snapshot = None
-        cls.shares = []
-        # Load all share data (host, etc.)
-        for share in shares_created:
-            cls.shares.append(cls.shares_v2_client.get_share(share['id']))
-            # Create snapshot
-            snap_name = data_utils.rand_name("tempest-snapshot-name")
-            snap_desc = data_utils.rand_name(
-                "tempest-snapshot-description")
-            snap = cls.create_snapshot_wait_for_active(
-                share['id'], snap_name, snap_desc)
-            cls.snapshot = cls.shares_v2_client.get_snapshot(snap['id'])
-            # Unmanage snapshot
-            cls.shares_v2_client.unmanage_snapshot(snap['id'])
-            cls.shares_client.wait_for_resource_deletion(
-                snapshot_id=snap['id'])
+        # Get updated data
+        cls.share = cls.shares_v2_client.get_share(cls.share['id'])
 
     def _test_manage(self, snapshot, version=CONF.share.max_api_microversion):
         name = ("Name for 'managed' snapshot that had ID %s" %
@@ -97,7 +81,8 @@
             snapshot['provider_location'],
             name=name,
             description=description,
-            driver_options={}
+            driver_options={},
+            version=version,
         )
 
         # Add managed snapshot to cleanup queue
@@ -109,6 +94,19 @@
         self.shares_v2_client.wait_for_snapshot_status(snapshot['id'],
                                                        'available')
 
+        # Verify manage snapshot API response
+        expected_keys = ["status", "links", "share_id", "name",
+                         "share_proto", "created_at",
+                         "description", "id", "share_size", "size",
+                         "provider_location"]
+        if utils.is_microversion_ge(version, '2.17'):
+            expected_keys.extend(["user_id", "project_id"])
+
+        actual_keys = snapshot.keys()
+
+        # Strict key check
+        self.assertEqual(set(expected_keys), set(actual_keys))
+
         # Verify data of managed snapshot
         get_snapshot = self.shares_v2_client.get_snapshot(snapshot['id'])
         self.assertEqual(name, get_snapshot['name'])
@@ -126,9 +124,31 @@
                           get_snapshot['id'])
 
     @test.attr(type=[base.TAG_POSITIVE, base.TAG_BACKEND])
-    def test_manage(self):
+    @ddt.data('2.12', '2.16', CONF.share.max_api_microversion)
+    def test_manage_different_versions(self, version):
+        """Run snapshot manage test for multiple versions.
+
+        This test is configured with ddt to run for the configured maximum
+        version as well as versions 2.12 (when the API was introduced) and
+        2.16.
+        """
+        # Skip in case specified version is not supported
+        utils.skip_if_microversion_not_supported(version)
+
+        snap_name = data_utils.rand_name("tempest-snapshot-name")
+        snap_desc = data_utils.rand_name("tempest-snapshot-description")
+        # Create snapshot
+        snapshot = self.create_snapshot_wait_for_active(
+            self.share['id'], snap_name, snap_desc)
+        snapshot = self.shares_v2_client.get_snapshot(snapshot['id'])
+        # Unmanage snapshot
+        self.shares_v2_client.unmanage_snapshot(snapshot['id'],
+                                                version=version)
+        self.shares_client.wait_for_resource_deletion(
+            snapshot_id=snapshot['id'])
+
         # Manage snapshot
-        self._test_manage(snapshot=self.snapshot)
+        self._test_manage(snapshot=snapshot, version=version)
 
 
 class ManageCIFSSnapshotTest(ManageNFSSnapshotTest):
diff --git a/manila_tempest_tests/tests/api/test_shares.py b/manila_tempest_tests/tests/api/test_shares.py
index 1da57e4..2acd81a 100644
--- a/manila_tempest_tests/tests/api/test_shares.py
+++ b/manila_tempest_tests/tests/api/test_shares.py
@@ -104,14 +104,26 @@
 
         # create snapshot
         snap = self.create_snapshot_wait_for_active(self.share["id"])
+
         detailed_elements = {'name', 'id', 'description',
                              'created_at', 'share_proto', 'size', 'share_size',
                              'share_id', 'status', 'links'}
-        self.assertTrue(detailed_elements.issubset(snap.keys()),
-                        'At least one expected element missing from snapshot '
-                        'response. Expected %(expected)s, got %(actual)s.' % {
-                            "expected": detailed_elements,
-                            "actual": snap.keys()})
+        msg = (
+            "At least one expected element missing from share "
+            "response. Expected %(expected)s, got %(actual)s." % {
+                "expected": detailed_elements,
+                "actual": snap.keys(),
+            }
+        )
+        self.assertTrue(detailed_elements.issubset(snap.keys()), msg)
+
+        # In v2.17 and beyond, we expect user_id and project_id keys
+        if utils.is_microversion_supported('2.17'):
+            detailed_elements.update({'user_id', 'project_id'})
+            self.assertTrue(detailed_elements.issubset(snap.keys()), msg)
+        else:
+            self.assertNotIn('user_id', detailed_elements)
+            self.assertNotIn('project_id', detailed_elements)
 
         # delete snapshot
         self.shares_client.delete_snapshot(snap["id"])
diff --git a/manila_tempest_tests/tests/api/test_shares_actions.py b/manila_tempest_tests/tests/api/test_shares_actions.py
index 16b8b58..3d4c54b 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 ddt
 import six
 from tempest import config
 from tempest.lib.common.utils import data_utils
@@ -23,8 +24,10 @@
 from manila_tempest_tests import utils
 
 CONF = config.CONF
+LATEST_MICROVERSION = CONF.share.max_api_microversion
 
 
+@ddt.ddt
 class SharesActionsTest(base.BaseSharesTest):
     """Covers share functionality, that doesn't related to share type."""
 
@@ -399,30 +402,58 @@
     @test.attr(type=[base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND])
     @testtools.skipUnless(CONF.share.run_snapshot_tests,
                           "Snapshot tests are disabled.")
-    def test_get_snapshot(self):
+    @ddt.data(None, '2.16', LATEST_MICROVERSION)
+    def test_get_snapshot(self, version):
 
         # get snapshot
-        get = self.shares_client.get_snapshot(self.snap["id"])
+        if version is None:
+            snapshot = self.shares_client.get_snapshot(self.snap["id"])
+        else:
+            utils.skip_if_microversion_not_supported(version)
+            snapshot = self.shares_v2_client.get_snapshot(
+                self.snap["id"], version=version)
 
         # verify keys
         expected_keys = ["status", "links", "share_id", "name",
                          "share_proto", "created_at",
-                         "description", "id", "share_size"]
-        actual_keys = get.keys()
-        [self.assertIn(key, actual_keys) for key in expected_keys]
+                         "description", "id", "share_size", "size"]
+        if version and utils.is_microversion_ge(version, '2.17'):
+            expected_keys.extend(["user_id", "project_id"])
+        actual_keys = snapshot.keys()
+
+        # strict key check
+        self.assertEqual(set(expected_keys), set(actual_keys))
 
         # verify data
         msg = "Expected name: '%s', actual name: '%s'" % (self.snap_name,
-                                                          get["name"])
-        self.assertEqual(self.snap_name, get["name"], msg)
+                                                          snapshot["name"])
+        self.assertEqual(self.snap_name, snapshot["name"], msg)
 
-        msg = "Expected description: '%s', "\
-              "actual description: '%s'" % (self.snap_desc, get["description"])
-        self.assertEqual(self.snap_desc, get["description"], msg)
+        msg = ("Expected description: '%s' actual description: '%s'" %
+               (self.snap_desc, snapshot["description"]))
+        self.assertEqual(self.snap_desc, snapshot["description"], msg)
 
-        msg = "Expected share_id: '%s', "\
-              "actual share_id: '%s'" % (self.shares[0]["id"], get["share_id"])
-        self.assertEqual(self.shares[0]["id"], get["share_id"], msg)
+        msg = ("Expected share_id: '%s', actual share_id: '%s'" %
+               (self.shares[0]["id"], snapshot["share_id"]))
+        self.assertEqual(self.shares[0]["id"], snapshot["share_id"], msg)
+
+        # Verify that the user_id and project_id are same as the one for
+        # the base share
+        if version and utils.is_microversion_ge(version, '2.17'):
+            msg = ("Expected %(key)s in snapshot: '%(expected)s', "
+                   "actual %(key)s in snapshot: '%(actual)s'")
+            self.assertEqual(self.shares[0]['user_id'],
+                             snapshot['user_id'],
+                             msg % {
+                                 'expected': self.shares[0]['user_id'],
+                                 'actual': snapshot['user_id'],
+                                 'key': 'user_id'})
+            self.assertEqual(self.shares[0]['project_id'],
+                             snapshot['project_id'],
+                             msg % {
+                                 'expected': self.shares[0]['project_id'],
+                                 'actual': snapshot['project_id'],
+                                 'key': 'project_id'})
 
     @test.attr(type=[base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND])
     @testtools.skipUnless(CONF.share.run_snapshot_tests,
@@ -444,16 +475,26 @@
     @test.attr(type=[base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND])
     @testtools.skipUnless(CONF.share.run_snapshot_tests,
                           "Snapshot tests are disabled.")
-    def test_list_snapshots_with_detail(self):
+    @ddt.data(None, '2.16', LATEST_MICROVERSION)
+    def test_list_snapshots_with_detail(self, version):
 
         # list share snapshots
-        snaps = self.shares_client.list_snapshots_with_detail()
+        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)
 
         # verify keys
-        keys = ["status", "links", "share_id", "name",
-                "share_proto", "created_at",
-                "description", "id", "share_size"]
-        [self.assertIn(key, sn.keys()) for sn in snaps for key in keys]
+        expected_keys = ["status", "links", "share_id", "name",
+                         "share_proto", "created_at", "description", "id",
+                         "share_size", "size"]
+        if version and utils.is_microversion_ge(version, '2.17'):
+            expected_keys.extend(["user_id", "project_id"])
+
+        # strict key check
+        [self.assertEqual(set(expected_keys), set(s.keys())) for s in snaps]
 
         # our share id in list and have no duplicates
         gen = [sid["id"] for sid in snaps if sid["id"] in self.snap["id"]]
