Do auth_url.rstrip('/') only if auth_url is set
auth_url can be None, for example, when we use bypass_url. Also, add rstrip('/') for bypass_url (and management_url), which is done when management_url is gotten from service catalog. Change-Id: I4f59cc405386a15f8a266d279b27f279eacdb7f1
This commit is contained in:
parent
14deb0194e
commit
4cfaa4a61c
novaclient
@ -83,7 +83,7 @@ class HTTPClient(object):
|
||||
auth_url = auth_plugin.get_auth_url()
|
||||
if not auth_url:
|
||||
raise exceptions.EndpointNotFound()
|
||||
self.auth_url = auth_url.rstrip('/')
|
||||
self.auth_url = auth_url.rstrip('/') if auth_url else auth_url
|
||||
self.version = 'v1.1'
|
||||
self.region_name = region_name
|
||||
self.endpoint_type = endpoint_type
|
||||
@ -91,7 +91,7 @@ class HTTPClient(object):
|
||||
self.service_name = service_name
|
||||
self.volume_service_name = volume_service_name
|
||||
self.timings = timings
|
||||
self.bypass_url = bypass_url
|
||||
self.bypass_url = bypass_url.rstrip('/') if bypass_url else bypass_url
|
||||
self.os_cache = os_cache or not no_cache
|
||||
self.http_log_debug = http_log_debug
|
||||
if timeout is not None:
|
||||
|
@ -216,3 +216,17 @@ class ClientTest(utils.TestCase):
|
||||
cs.password_func = mock.Mock()
|
||||
self.assertEqual(cs._get_password(), "password")
|
||||
self.assertFalse(cs.password_func.called)
|
||||
|
||||
def test_auth_url_rstrip_slash(self):
|
||||
cs = novaclient.client.HTTPClient("user", "password", "project_id",
|
||||
auth_url="foo/v2/")
|
||||
self.assertEqual(cs.auth_url, "foo/v2")
|
||||
|
||||
def test_token_and_bypass_url(self):
|
||||
cs = novaclient.client.HTTPClient(None, None, None,
|
||||
auth_token="12345",
|
||||
bypass_url="compute/v100/")
|
||||
self.assertIsNone(cs.auth_url)
|
||||
self.assertEqual(cs.auth_token, "12345")
|
||||
self.assertEqual(cs.bypass_url, "compute/v100")
|
||||
self.assertEqual(cs.management_url, "compute/v100")
|
||||
|
Loading…
x
Reference in New Issue
Block a user