Check 'auth_url' is presented while authentication
If 'auth_url' is missed in HTTPClient, authenticate method failed with non-friendly error while trying to parse it. Change-Id: Iaec95527293f3e1a34eb7f9ffa81097ba48107b3
This commit is contained in:
parent
578390ee7e
commit
f84c6531fd
@ -586,6 +586,10 @@ class HTTPClient(object):
|
||||
extract_token=False)
|
||||
|
||||
def authenticate(self):
|
||||
if not self.auth_url:
|
||||
msg = _("Authentication requires 'auth_url', which should be "
|
||||
"specified in '%s'") % self.__class__.__name__
|
||||
raise exceptions.AuthorizationFailure(msg)
|
||||
magic_tuple = netutils.urlsplit(self.auth_url)
|
||||
scheme, netloc, path, query, frag = magic_tuple
|
||||
port = magic_tuple.port
|
||||
|
@ -141,6 +141,11 @@ class ClientTest(utils.TestCase):
|
||||
|
||||
test_auth_call()
|
||||
|
||||
def test_auth_failure_due_to_miss_of_auth_url(self):
|
||||
cl = client.HTTPClient("username", "password")
|
||||
|
||||
self.assertRaises(exceptions.AuthorizationFailure, cl.authenticate)
|
||||
|
||||
def test_connection_refused(self):
|
||||
cl = get_client()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user