missed a file
This commit is contained in:
parent
6495d41ac2
commit
c8ed28c7d3
|
@ -187,6 +187,8 @@ class SqlIdentity(SqlBase):
|
|||
extras_ref = None
|
||||
if not user_ref or user_ref.get('password') != password:
|
||||
raise AssertionError('Invalid user / password')
|
||||
|
||||
tenants = self.get_tenants_for_user(user_id)
|
||||
if tenant_id and tenant_id not in user_ref['tenants']:
|
||||
raise AssertionError('Invalid tenant')
|
||||
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
class IdentityTests(object):
|
||||
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'])
|
||||
|
||||
def test_authenticate_no_tenant(self):
|
||||
user_ref, tenant_ref, extras_ref = self.identity_api.authenticate(
|
||||
user_id=self.user_foo['id'],
|
||||
password=self.user_foo['password'])
|
||||
self.assertDictEquals(user_ref, self.user_foo)
|
||||
self.assert_(tenant_ref is None)
|
||||
self.assert_(not extras_ref)
|
||||
|
||||
def test_authenticate(self):
|
||||
user_ref, tenant_ref, extras_ref = self.identity_api.authenticate(
|
||||
user_id=self.user_foo['id'],
|
||||
tenant_id=self.tenant_bar['id'],
|
||||
password=self.user_foo['password'])
|
||||
self.assertDictEquals(user_ref, self.user_foo)
|
||||
self.assertDictEquals(tenant_ref, self.tenant_bar)
|
||||
self.assertDictEquals(extras_ref, self.extras_foobar)
|
||||
|
||||
def test_get_tenant_bad_tenant(self):
|
||||
tenant_ref = self.identity_api.get_tenant(
|
||||
tenant_id=self.tenant_bar['id'] + 'WRONG')
|
||||
self.assert_(tenant_ref is None)
|
||||
|
||||
def test_get_tenant(self):
|
||||
tenant_ref = self.identity_api.get_tenant(tenant_id=self.tenant_bar['id'])
|
||||
self.assertDictEquals(tenant_ref, self.tenant_bar)
|
||||
|
||||
def test_get_tenant_by_name_bad_tenant(self):
|
||||
tenant_ref = self.identity_api.get_tenant(
|
||||
tenant_id=self.tenant_bar['name'] + 'WRONG')
|
||||
self.assert_(tenant_ref is None)
|
||||
|
||||
def test_get_tenant_by_name(self):
|
||||
tenant_ref = self.identity_api.get_tenant_by_name(
|
||||
tenant_name=self.tenant_bar['name'])
|
||||
self.assertDictEquals(tenant_ref, self.tenant_bar)
|
||||
|
||||
def test_get_user_bad_user(self):
|
||||
user_ref = self.identity_api.get_user(
|
||||
user_id=self.user_foo['id'] + 'WRONG')
|
||||
self.assert_(user_ref is None)
|
||||
|
||||
def test_get_user(self):
|
||||
user_ref = self.identity_api.get_user(user_id=self.user_foo['id'])
|
||||
self.assertDictEquals(user_ref, self.user_foo)
|
||||
|
||||
def test_get_extras_bad_user(self):
|
||||
extras_ref = self.identity_api.get_extras(
|
||||
user_id=self.user_foo['id'] + 'WRONG',
|
||||
tenant_id=self.tenant_bar['id'])
|
||||
self.assert_(extras_ref is None)
|
||||
|
||||
def test_get_extras_bad_tenant(self):
|
||||
extras_ref = self.identity_api.get_extras(
|
||||
user_id=self.user_foo['id'],
|
||||
tenant_id=self.tenant_bar['id'] + 'WRONG')
|
||||
self.assert_(extras_ref is None)
|
||||
|
||||
def test_get_extras(self):
|
||||
extras_ref = self.identity_api.get_extras(
|
||||
user_id=self.user_foo['id'],
|
||||
tenant_id=self.tenant_bar['id'])
|
||||
self.assertDictEquals(extras_ref, self.extras_foobar)
|
||||
|
||||
def test_get_role(self):
|
||||
role_ref = self.identity_api.get_role(
|
||||
role_id=self.role_keystone_admin['id'])
|
||||
self.assertDictEquals(role_ref, self.role_keystone_admin)
|
||||
|
||||
|
|
@ -4,11 +4,11 @@ from keystonelight import models
|
|||
from keystonelight import test
|
||||
from keystonelight.backends import kvs
|
||||
|
||||
import test_backends
|
||||
import test_backend
|
||||
import default_fixtures
|
||||
|
||||
|
||||
class KvsIdentity(test.TestCase, test_backends.IdentityTests):
|
||||
class KvsIdentity(test.TestCase, test_backend.IdentityTests):
|
||||
def setUp(self):
|
||||
super(KvsIdentity, self).setUp()
|
||||
self.options = self.appconfig('default')
|
||||
|
|
|
@ -6,11 +6,11 @@ from keystonelight import test
|
|||
from keystonelight.backends import sql
|
||||
from keystonelight.backends.sql import migration
|
||||
|
||||
import test_backends
|
||||
import test_backend
|
||||
import default_fixtures
|
||||
|
||||
|
||||
class SqlIdentity(test.TestCase, test_backends.IdentityTests):
|
||||
class SqlIdentity(test.TestCase, test_backend.IdentityTests):
|
||||
def setUp(self):
|
||||
super(SqlIdentity, self).setUp()
|
||||
self.options = self.appconfig('default')
|
||||
|
|
Loading…
Reference in New Issue