diff --git a/novaclient/client.py b/novaclient/client.py index b2a59474f..847115261 100644 --- a/novaclient/client.py +++ b/novaclient/client.py @@ -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 diff --git a/novaclient/tests/unit/test_http.py b/novaclient/tests/unit/test_http.py index 671ab09da..1cebe1f07 100644 --- a/novaclient/tests/unit/test_http.py +++ b/novaclient/tests/unit/test_http.py @@ -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()