add a couple more tests

This commit is contained in:
termie 2012-01-12 12:45:08 -08:00
parent 8ea6e8f497
commit 1bd1349482
3 changed files with 40 additions and 11 deletions

1
TODO
View File

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

View File

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

View File

@ -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'])