update how user is specified in tests

This commit is contained in:
Jesse Andrews 2012-01-19 15:44:48 -08:00
parent c1fe99854c
commit cbc1558ea6
2 changed files with 15 additions and 16 deletions

View File

@ -5,12 +5,12 @@ TENANTS = [
USERS = [
{'id': 'foo', 'name': 'FOO', 'password': 'foo2', 'tenants': ['bar',]},
{'id': 'boo', 'name': 'BOO', 'password': 'boo2', 'tenants': ['baz',]},
{'id': 'two', 'name': 'TWO', 'password': 'two2', 'tenants': ['baz',]},
]
METADATA = [
{'user_id': 'foo', 'tenant_id': 'bar', 'extra': 'extra'},
{'user_id': 'boo', 'tenant_id': 'baz', 'extra': 'extra'},
{'user_id': 'two', 'tenant_id': 'baz', 'extra': 'extra'},
]
ROLES = [

View File

@ -65,14 +65,13 @@ class KcMasterTestCase(CompatTestCase):
CONF(config_files=[test.etcdir('keystone.conf'),
test.testsdir('test_overrides.conf')])
def get_client(self, username='FOO'):
users = [u for u in default_fixtures.USERS if u['name'] == username]
self.assertEquals(1, len(users))
user = users[0]
def get_client(self, user_ref=None):
if user_ref is None:
user_ref = self.user_foo
return self._client(username=user['name'],
password=user['password'],
tenant_id=user['tenants'][0])
return self._client(username=user_ref['name'],
password=user_ref['password'],
tenant_id=user_ref['tenants'][0])
def test_authenticate_tenant_name_and_tenants(self):
client = self.get_client()
@ -266,8 +265,8 @@ class KcMasterTestCase(CompatTestCase):
def test_ec2_credentials_list_unauthorized_user(self):
from keystoneclient import exceptions as client_exceptions
boo = self.get_client('BOO')
self.assertRaises(client_exceptions.Unauthorized, boo.ec2.list,
two = self.get_client(self.user_two)
self.assertRaises(client_exceptions.Unauthorized, two.ec2.list,
self.user_foo['id'])
def test_ec2_credentials_get_unauthorized_user(self):
@ -276,8 +275,8 @@ class KcMasterTestCase(CompatTestCase):
foo = self.get_client()
cred = foo.ec2.create(self.user_foo['id'], self.tenant_bar['id'])
boo = self.get_client('BOO')
self.assertRaises(client_exceptions.Unauthorized, boo.ec2.get,
two = self.get_client(self.user_two)
self.assertRaises(client_exceptions.Unauthorized, two.ec2.get,
self.user_foo['id'], cred.access)
foo.ec2.delete(self.user_foo['id'], cred.access)
@ -288,8 +287,8 @@ class KcMasterTestCase(CompatTestCase):
foo = self.get_client()
cred = foo.ec2.create(self.user_foo['id'], self.tenant_bar['id'])
boo = self.get_client('BOO')
self.assertRaises(client_exceptions.Unauthorized, boo.ec2.delete,
two = self.get_client(self.user_two)
self.assertRaises(client_exceptions.Unauthorized, two.ec2.delete,
self.user_foo['id'], cred.access)
foo.ec2.delete(self.user_foo['id'], cred.access)