Merge "[osclients] do not always strip auth_url"
This commit is contained in:
commit
3e76273328
|
@ -52,7 +52,7 @@ then
|
|||
"type": "ExistingCloud",
|
||||
"creds": {
|
||||
"openstack": {
|
||||
"auth_url": "$KEYSTONE_AUTH_URI/v$IDENTITY_API_VERSION",
|
||||
"auth_url": "$OS_AUTH_URL",
|
||||
"region_name": "$REGION_NAME",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
|
@ -71,7 +71,7 @@ then
|
|||
"type": "ExistingCloud",
|
||||
"creds": {
|
||||
"openstack": {
|
||||
"auth_url": "$KEYSTONE_AUTH_URI_V3",
|
||||
"auth_url": "$OS_AUTH_URL",
|
||||
"region_name": "$REGION_NAME",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
|
|
|
@ -287,10 +287,13 @@ class Keystone(OSClient):
|
|||
if a version override is used.
|
||||
"""
|
||||
url = parse.urlparse(self.credential.auth_url)
|
||||
path = os.path.join(*os.path.split(url.path)[:-1])
|
||||
parts = (url.scheme, url.netloc, path, url.params, url.query,
|
||||
url.fragment)
|
||||
return parse.urlunparse(parts)
|
||||
path = url.path.rstrip("/")
|
||||
if path.endswith("v2.0") or path.endswith("v3"):
|
||||
path = os.path.join(*os.path.split(path)[:-1])
|
||||
parts = (url.scheme, url.netloc, path, url.params, url.query,
|
||||
url.fragment)
|
||||
return parse.urlunparse(parts)
|
||||
return self.credential.auth_url
|
||||
|
||||
def create_client(self, version=None):
|
||||
"""Return a keystone client.
|
||||
|
|
|
@ -210,6 +210,23 @@ class TestCreateKeystoneClient(test.TestCase, OSClientTestCaseUtils):
|
|||
{"session": self.ksa_session, "timeout": 180.0, "version": "3"},
|
||||
called_with)
|
||||
|
||||
@ddt.data({"original": "https://example.com/identity/foo/v3",
|
||||
"cropped": "https://example.com/identity/foo"},
|
||||
{"original": "https://example.com/identity/foo/v3/",
|
||||
"cropped": "https://example.com/identity/foo"},
|
||||
{"original": "https://example.com/identity/foo/v2.0",
|
||||
"cropped": "https://example.com/identity/foo"},
|
||||
{"original": "https://example.com/identity/foo/v2.0/",
|
||||
"cropped": "https://example.com/identity/foo"},
|
||||
{"original": "https://example.com/identity/foo",
|
||||
"cropped": "https://example.com/identity/foo"})
|
||||
@ddt.unpack
|
||||
def test__remove_url_version(self, original, cropped):
|
||||
credential = oscredential.OpenStackCredential(
|
||||
original, "user", "pass", "tenant")
|
||||
keystone = osclients.Keystone(credential, {}, {})
|
||||
self.assertEqual(cropped, keystone._remove_url_version())
|
||||
|
||||
@ddt.data("http://auth_url/v2.0", "http://auth_url/v3",
|
||||
"http://auth_url/", "auth_url")
|
||||
def test_keystone_get_session(self, auth_url):
|
||||
|
|
Loading…
Reference in New Issue