add some failing tests
This commit is contained in:
parent
b514897be6
commit
4c8a5ac747
|
@ -12,10 +12,18 @@ class KvsIdentity(object):
|
|||
def __init__(self, options, db=None):
|
||||
if db is None:
|
||||
db = INMEMDB
|
||||
elif type(db) is type({}):
|
||||
db = DictKvs(db)
|
||||
self.db = db
|
||||
|
||||
# Public interface
|
||||
def authenticate(self, user_id=None, tenant_id=None, password=None):
|
||||
"""Authenticate based on a user, tenant and password.
|
||||
|
||||
Expects the user object to have a password field and the tenant to be
|
||||
in the list of tenants on the user.
|
||||
|
||||
"""
|
||||
user_ref = self.get_user(user_id)
|
||||
tenant_ref = None
|
||||
extras_ref = None
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
|
||||
from keystonelight import models
|
||||
from keystonelight import test
|
||||
from keystonelight.backends import kvs
|
||||
|
||||
|
||||
class KvsIdentity(test.TestCase):
|
||||
def setUp(self):
|
||||
super(KvsIdentity, self).setUp()
|
||||
options = self.appconfig('default')
|
||||
self.identity_api = kvs.KvsIdentity(options=options, db={})
|
||||
self._load_fixtures()
|
||||
|
||||
def _load_fixtures(self):
|
||||
self.tenant_bar = self.identity_api._create_tenant(
|
||||
'bar',
|
||||
models.Tenant(id='bar', name='BAR'))
|
||||
self.user_foo = self.identity_api._create_user(
|
||||
'foo',
|
||||
models.User(id='foo',
|
||||
name='FOO',
|
||||
password='foo2',
|
||||
tenants=[self.tenant_bar['id']]))
|
||||
|
||||
|
||||
def test_authenticate_bad_user(self):
|
||||
self.assertRaises(AssertionError,
|
||||
self.identity_api.authenticate,
|
||||
user_id=self.user_foo['id'] + 'WRONG',
|
||||
tenant_id=self.tenant_bar['id'],
|
||||
password=self.user_foo['password'])
|
||||
|
||||
def test_authenticate_bad_password(self):
|
||||
self.assertRaises(AssertionError,
|
||||
self.identity_api.authenticate,
|
||||
user_id=self.user_foo['id'],
|
||||
tenant_id=self.tenant_bar['id'],
|
||||
password=self.user_foo['password'] + 'WRONG')
|
||||
|
||||
|
||||
def test_authenticate_invalid_tenant(self):
|
||||
self.assertRaises(AssertionError,
|
||||
self.identity_api.authenticate,
|
||||
user_id=self.user_foo['id'],
|
||||
tenant_id=self.tenant_bar['id'] + 'WRONG',
|
||||
password=self.user_foo['password'])
|
Loading…
Reference in New Issue