Browse Source

add a couple more tests

changes/73/3573/1
termie 10 years ago
parent
commit
1bd1349482
  1. 1
      TODO
  2. 26
      keystone/service.py
  3. 24
      tests/test_keystoneclient.py

1
TODO

@ -1,4 +1,3 @@
- test authenticate with token only
- test validate token
- policy tests
- ec2 support

26
keystone/service.py

@ -426,24 +426,30 @@ class TokenController(Application):
tenants = self.identity_api.get_tenants_for_user(context,
user_ref['id'])
assert tenant_id in tenants
if tenant_id:
assert tenant_id in tenants
tenant_ref = self.identity_api.get_tenant(context=context,
tenant_id=tenant_id)
metadata_ref = self.identity_api.get_metadata(
context=context,
user_id=user_ref['id'],
tenant_id=tenant_ref['id'])
if tenant_ref:
metadata_ref = self.identity_api.get_metadata(
context=context,
user_id=user_ref['id'],
tenant_id=tenant_ref['id'])
catalog_ref = self.catalog_api.get_catalog(
context=context,
user_id=user_ref['id'],
tenant_id=tenant_ref['id'],
metadata=metadata_ref)
else:
metadata_ref = {}
catalog_ref = {}
token_ref = self.token_api.create_token(
context, dict(expires='',
user=user_ref,
tenant=tenant_ref,
metadata=metadata_ref))
catalog_ref = self.catalog_api.get_catalog(
context=context,
user_id=user_ref['id'],
tenant_id=tenant_ref['id'],
metadata=metadata_ref)
# TODO(termie): optimize this call at some point and put it into the
# the return for metadata

24
tests/test_keystoneclient.py

@ -76,7 +76,31 @@ class KcMasterTestCase(CompatTestCase):
self.assertEquals(tenants[0].id, self.tenant_bar['id'])
def test_authenticate_tenant_id_and_tenants(self):
client = self._client(username='FOO',
password='foo2',
tenant_id='bar')
tenants = client.tenants.list()
self.assertEquals(tenants[0].id, self.tenant_bar['id'])
def test_authenticate_token_no_tenant(self):
client = self.foo_client()
token = client.auth_token
token_client = self._client(token=token)
tenants = client.tenants.list()
self.assertEquals(tenants[0].id, self.tenant_bar['id'])
def test_authenticate_token_tenant_id(self):
client = self.foo_client()
token = client.auth_token
token_client = self._client(token=token, tenant_id='bar')
tenants = client.tenants.list()
self.assertEquals(tenants[0].id, self.tenant_bar['id'])
def test_authenticate_token_tenant_name(self):
client = self.foo_client()
token = client.auth_token
token_client = self._client(token=token, tenant_name='BAR')
tenants = client.tenants.list()
self.assertEquals(tenants[0].id, self.tenant_bar['id'])

Loading…
Cancel
Save