Address bug 1839794 on the Volume show version client

Bug https://bugs.launchpad.net/tempest/+bug/1839794
found out that the volume version_show client that
was not used had a defect when builing the URL.
Used the same direction that the compute version client
did to strip off the version and project info and add
back the version.[0] Also added a Volume v3 test using the
client.

[0] https://github.com/openstack/tempest/blob/master/tempest/lib/services/compute/versions_client.py#L40

Change-Id: I9be99f5fc0eab3de125ce69415a0be65b1c4ad0d
Closes-Bug: #1839794
diff --git a/tempest/api/volume/test_versions.py b/tempest/api/volume/test_versions.py
index b4d48db..b602032 100644
--- a/tempest/api/volume/test_versions.py
+++ b/tempest/api/volume/test_versions.py
@@ -27,3 +27,15 @@
         #       with JSON-Schema validation. It is enough to just call
         #       the API here.
         self.versions_client.list_versions()
+
+    @decorators.idempotent_id('7f755ae2-caa9-4049-988c-331d8f7a579f')
+    def test_show_version(self):
+        # NOTE: The version data is checked on service client side
+        # with JSON-Schema validation. So we will loop through each
+        # version and call show version.
+        versions = self.versions_client.list_versions()['versions']
+        for version_dict in versions:
+            version = version_dict['id']
+            major_version = version.split('.')[0]
+            response = self.versions_client.show_version(major_version)
+            self.assertEqual(version, response['versions'][0]['id'])
diff --git a/tempest/lib/services/volume/v3/versions_client.py b/tempest/lib/services/volume/v3/versions_client.py
index fc8e92f..175f1f5 100644
--- a/tempest/lib/services/volume/v3/versions_client.py
+++ b/tempest/lib/services/volume/v3/versions_client.py
@@ -12,9 +12,10 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import os
 import time
 
+from six.moves.urllib.parse import urljoin
+
 from oslo_serialization import jsonutils as json
 
 from tempest.lib.api_schema.response.volume import versions as schema
@@ -50,13 +51,18 @@
     def show_version(self, version):
         """Show API version details
 
+        Use raw_request in order to have access to the endpoints minus
+        version and project in order to add version only back.
+
         For a full list of available parameters, please refer to the official
         API reference:
         https://docs.openstack.org/api-ref/block-storage/v3/#show-api-v3-details
         """
 
-        version_url = os.path.join(self._get_base_version_url(), version)
-        resp, body = self.get(version_url)
+        version_url = urljoin(self._get_base_version_url(), version + '/')
+        resp, body = self.raw_request(version_url, 'GET',
+                                      {'X-Auth-Token': self.token})
+        self._error_checker(resp, body)
         body = json.loads(body)
         self.validate_response(schema.volume_api_version_details, resp, body)
         return rest_client.ResponseBody(resp, body)
diff --git a/tempest/tests/lib/services/volume/v3/test_versions_client.py b/tempest/tests/lib/services/volume/v3/test_versions_client.py
index b9abd45..575cae3 100644
--- a/tempest/tests/lib/services/volume/v3/test_versions_client.py
+++ b/tempest/tests/lib/services/volume/v3/test_versions_client.py
@@ -97,6 +97,14 @@
                                                      'volume',
                                                      'regionOne')
 
+    def _test_get_base_version_url(self, url, expected_base_url):
+        fake_auth = fake_auth_provider.FakeAuthProvider(fake_base_url=url)
+        client = versions_client.VersionsClient(fake_auth,
+                                                'volume',
+                                                'regionOne')
+        self.assertEqual(expected_base_url,
+                         client._get_base_version_url())
+
     def _test_list_versions(self, bytes_body=False):
         self.check_service_client_function(
             self.client.list_versions,
@@ -105,22 +113,30 @@
             bytes_body,
             300)
 
+    def _test_show_version(self, version, bytes_body=False):
+        self.check_service_client_function(
+            self.client.show_version,
+            'tempest.lib.common.rest_client.RestClient.raw_request',
+            self.FAKE_VERSION_DETAILS,
+            bytes_body,
+            200, version=version)
+
     def test_list_versions_with_str_body(self):
         self._test_list_versions()
 
     def test_list_versions_with_bytes_body(self):
         self._test_list_versions(bytes_body=True)
 
-    def _test_show_version(self, bytes_body=False):
-        self.check_service_client_function(
-            self.client.show_version,
-            'tempest.lib.common.rest_client.RestClient.get',
-            self.FAKE_VERSION_DETAILS,
-            bytes_body,
-            200, version='v3')
-
     def test_show_version_details_with_str_body(self):
-        self._test_show_version()
+        self._test_show_version('v3')
 
     def test_show_version_details_with_bytes_body(self):
-        self._test_show_version(bytes_body=True)
+        self._test_show_version('v3', bytes_body=True)
+
+    def test_get_base_version_url_app_name(self):
+        self._test_get_base_version_url('https://bar.org/volume/v1/123',
+                                        'https://bar.org/volume/')
+        self._test_get_base_version_url('https://bar.org/volume/v2/123',
+                                        'https://bar.org/volume/')
+        self._test_get_base_version_url('https://bar.org/volume/v3/123',
+                                        'https://bar.org/volume/')