summaryrefslogtreecommitdiffstats
path: root/keystone
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-03-02 19:08:55 +0000
committerGerrit Code Review <review@openstack.org>2012-03-02 19:08:55 +0000
commitca97ac85513853b50fcac73f77ceadc9cf36df7e (patch)
treed1b0fbd6089aa65aa75131a961777a29715f2d3a /keystone
parentea4999d22e325ccb915a9f59d6dd5b996cfed319 (diff)
parentdd35d2afbfc7bcd41cd5c68b440f5c502d32d656 (diff)
downloadkeystone-ca97ac85513853b50fcac73f77ceadc9cf36df7e.tar.gz
keystone-ca97ac85513853b50fcac73f77ceadc9cf36df7e.tar.xz
keystone-ca97ac85513853b50fcac73f77ceadc9cf36df7e.zip
Merge "standardize ldap and related tests"
Diffstat (limited to 'keystone')
-rw-r--r--keystone/identity/backends/kvs.py4
-rw-r--r--keystone/identity/backends/ldap/core.py18
-rw-r--r--keystone/identity/backends/sql.py2
3 files changed, 7 insertions, 17 deletions
diff --git a/keystone/identity/backends/kvs.py b/keystone/identity/backends/kvs.py
index 35ac476d..1e1c6ad6 100644
--- a/keystone/identity/backends/kvs.py
+++ b/keystone/identity/backends/kvs.py
@@ -49,7 +49,9 @@ class Identity(kvs.Base, identity.Driver):
if (not user_ref
or not utils.check_password(password, user_ref.get('password'))):
raise AssertionError('Invalid user / password')
- if tenant_id and tenant_id not in user_ref['tenants']:
+
+ tenants = self.get_tenants_for_user(user_id)
+ if tenant_id and tenant_id not in tenants:
raise AssertionError('Invalid tenant')
tenant_ref = self.get_tenant(tenant_id)
diff --git a/keystone/identity/backends/ldap/core.py b/keystone/identity/backends/ldap/core.py
index 409a384a..3138720f 100644
--- a/keystone/identity/backends/ldap/core.py
+++ b/keystone/identity/backends/ldap/core.py
@@ -74,17 +74,11 @@ class Identity(identity.Driver):
except Exception:
raise AssertionError('Invalid user / password')
- if tenant_id:
- found = False
- for tenant in user_ref['tenants']:
- if tenant == tenant_id:
- found = True
- break
+ tenants = self.get_tenants_for_user(user_id)
+ if tenant_id and tenant_id not in tenants:
+ raise AssertionError('Invalid tenant')
- if not found:
- raise AssertionError('Invalid tenant')
-
- tenant_ref = self.tenant.get(tenant_id)
+ tenant_ref = self.get_tenant(tenant_id)
metadata_ref = {}
# TODO(termie): this should probably be made into a get roles call
#if tenant_ref:
@@ -103,10 +97,6 @@ class Identity(identity.Driver):
user_ref = self.user.get(user_id)
if not user_ref:
return None
- tenants = self.tenant.get_user_tenants(user_id)
- user_ref['tenants'] = []
- for tenant in tenants:
- user_ref['tenants'].append(tenant['id'])
return user_ref
def get_user(self, user_id):
diff --git a/keystone/identity/backends/sql.py b/keystone/identity/backends/sql.py
index adc33b12..cf1f70e2 100644
--- a/keystone/identity/backends/sql.py
+++ b/keystone/identity/backends/sql.py
@@ -128,8 +128,6 @@ class Identity(sql.Base, identity.Driver):
"""
user_ref = self._get_user(user_id)
- tenant_ref = None
- metadata_ref = None
if (not user_ref
or not utils.check_password(password, user_ref.get('password'))):
raise AssertionError('Invalid user / password')