Merge "Check 'auth_url' is presented while authentication"

This commit is contained in:
Jenkins 2015-02-10 17:25:43 +00:00 committed by Gerrit Code Review
commit 65bd6245d1
2 changed files with 9 additions and 0 deletions

View File

@ -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

View File

@ -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()