Skip to content

Commit

Permalink
Merge "Raises Exception on improper Auth Configuration"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Oct 4, 2012
2 parents 6a86308 + a9a66ae commit c8696a5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions novaclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def __init__(self, user, password, projectid, auth_url=None,
self.projectid = projectid
if not auth_url and auth_system and auth_system != 'keystone':
auth_url = get_auth_system_url(auth_system)
if not auth_url:
raise exceptions.EndpointNotFound()
self.auth_url = auth_url.rstrip('/')
self.version = 'v1.1'
self.region_name = region_name
Expand Down
24 changes: 24 additions & 0 deletions tests/test_auth_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,27 @@ def test_auth_call():
self.assertEquals(cs.client.auth_url, "http://faked/v2.0")

test_auth_call()

def test_auth_system_raises_exception_when_missing_auth_url(self):
class MockAuthUrlEntrypoint(pkg_resources.EntryPoint):
def load(self):
return self.auth_url

def auth_url(self):
return None

def mock_iter_entry_points(_type):
return [MockAuthUrlEntrypoint("fakewithauthurl",
"fakewithauthurl.plugin",
["auth_url"])]

@mock.patch.object(pkg_resources, "iter_entry_points",
mock_iter_entry_points)
def test_auth_call():
with self.assertRaises(exceptions.EndpointNotFound):
cs = client.Client("username", "password", "project_id",
auth_system="fakewithauthurl",
no_cache=True)

test_auth_call()

0 comments on commit c8696a5

Please sign in to comment.