Merge "Fix the detection of v2 in the name"
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
import json
|
||||
import requests
|
||||
|
||||
from pathlib import PurePosixPath
|
||||
from six.moves import urllib
|
||||
|
||||
from config_tempest.constants import LOG
|
||||
@@ -30,14 +31,15 @@ class IdentityService(VersionedService):
|
||||
client, **kwargs)
|
||||
self.extensions_v3 = []
|
||||
version = ''
|
||||
if 'v2' in self.service_url:
|
||||
url_parse = urllib.parse.urlparse(self.service_url)
|
||||
if PurePosixPath(url_parse.path).name.startswith('v2'):
|
||||
version = '/v2.0'
|
||||
url_parse = urllib.parse.urlparse(self.service_url)
|
||||
self.service_url = '{}://{}{}'.format(url_parse.scheme,
|
||||
url_parse.netloc, version)
|
||||
|
||||
def set_extensions(self):
|
||||
if 'v2' in self.service_url:
|
||||
url_parse = urllib.parse.urlparse(self.service_url)
|
||||
if PurePosixPath(url_parse.path).name.startswith('v2'):
|
||||
body = self.do_get(self.service_url + '/extensions')
|
||||
body = json.loads(body)
|
||||
values = body['extensions']['values']
|
||||
|
||||
@@ -94,3 +94,29 @@ class TestIdentityService(BaseServiceTest):
|
||||
'forbid_global_implied_dsr'), 'True')
|
||||
self.assertEqual(
|
||||
conf.get('identity', 'auth_version'), 'v3')
|
||||
|
||||
|
||||
class TestIdentityServiceParseV2(BaseServiceTest):
|
||||
def setUp(self):
|
||||
super(TestIdentityServiceParseV2, self).setUp()
|
||||
|
||||
def _check_parse_v2_v3_uri(self, service_uri, expected_uri):
|
||||
self.Service = IdentityService("ServiceName",
|
||||
"ServiceType",
|
||||
service_uri,
|
||||
self.FAKE_TOKEN,
|
||||
disable_ssl_validation=False)
|
||||
self.assertEqual(self.Service.service_url, expected_uri)
|
||||
|
||||
def test_parse_name_with_v2(self):
|
||||
service_fake_url = "http://foobarv2/v3"
|
||||
self._check_parse_v2_v3_uri(service_fake_url, service_fake_url)
|
||||
|
||||
def test_parse_name_with_v2_in_path_1(self):
|
||||
service_fake_url = "https://an.example.com/mcyloudv2/v3"
|
||||
self._check_parse_v2_v3_uri(service_fake_url, service_fake_url)
|
||||
|
||||
def test_parse_name_with_v2_in_path_2(self):
|
||||
service_fake_url = "https://my.example.com/v2"
|
||||
self._check_parse_v2_v3_uri(service_fake_url,
|
||||
"https://my.example.com/v2.0")
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fix the detection of identity URIs which contains the string 'v2'.
|
||||
Previously the detection happened on the full URI, while the path
|
||||
component only should have been checked.
|
||||
Long term, support for Identity v2 will be removed.
|
||||
Reference in New Issue
Block a user