diff --git a/keystone/identity/backends/kvs.py b/keystone/identity/backends/kvs.py index 6922a1c17b..1d8ce608ec 100644 --- a/keystone/identity/backends/kvs.py +++ b/keystone/identity/backends/kvs.py @@ -63,8 +63,9 @@ class Identity(kvs.Base, identity.Driver): except exception.NotFound: raise exception.ProjectNotFound(project_id=tenant_id) - def get_projects(self): - tenant_keys = filter(lambda x: x.startswith("tenant-"), self.db.keys()) + def list_projects(self): + tenant_keys = filter(lambda x: x.startswith("tenant-"), + self.db.keys()) return [self.db.get(key) for key in tenant_keys] def get_project_by_name(self, tenant_name, domain_id): @@ -77,7 +78,8 @@ class Identity(kvs.Base, identity.Driver): self.get_project(tenant_id) user_keys = filter(lambda x: x.startswith("user-"), self.db.keys()) user_refs = [self.db.get(key) for key in user_keys] - return filter(lambda x: tenant_id in x['tenants'], user_refs) + user_refs = filter(lambda x: tenant_id in x['tenants'], user_refs) + return [identity.filter_user(user_ref) for user_ref in user_refs] def _get_user(self, user_id): try: @@ -539,7 +541,8 @@ class Identity(kvs.Base, identity.Driver): return domain def list_domains(self): - return self.db.get('domain_list', []) + domain_ids = self.db.get('domain_list', []) + return [self.get_domain(x) for x in domain_ids] def get_domain(self, domain_id): try: @@ -580,7 +583,8 @@ class Identity(kvs.Base, identity.Driver): return group def list_groups(self): - return self.db.get('group_list', []) + group_ids = self.db.get('group_list', []) + return [self.get_group(x) for x in group_ids] def get_group(self, group_id): try: diff --git a/keystone/identity/backends/ldap/core.py b/keystone/identity/backends/ldap/core.py index f9b2632cf9..db95e24634 100644 --- a/keystone/identity/backends/ldap/core.py +++ b/keystone/identity/backends/ldap/core.py @@ -103,7 +103,7 @@ class Identity(identity.Driver): except exception.NotFound: raise exception.ProjectNotFound(project_id=tenant_id) - def get_projects(self): + def list_projects(self): return self.project.get_all() def get_project_by_name(self, tenant_name, domain_id): diff --git a/keystone/identity/backends/pam.py b/keystone/identity/backends/pam.py index 3aa87c400c..1a312a27ea 100644 --- a/keystone/identity/backends/pam.py +++ b/keystone/identity/backends/pam.py @@ -102,9 +102,6 @@ class PamIdentity(identity.Driver): def remove_user_from_project(self, tenant_id, user_id): pass - def get_all_projects(self): - raise NotImplementedError() - def get_projects_for_user(self, user_id): return [user_id] diff --git a/keystone/identity/backends/sql.py b/keystone/identity/backends/sql.py index 8004a4167d..1d821287bb 100644 --- a/keystone/identity/backends/sql.py +++ b/keystone/identity/backends/sql.py @@ -406,14 +406,11 @@ class Identity(sql.Base, identity.Driver): session.delete(membership_ref) session.flush() - def get_projects(self): + def list_projects(self): session = self.get_session() tenant_refs = session.query(Project).all() return [tenant_ref.to_dict() for tenant_ref in tenant_refs] - def list_projects(self): - return self.get_projects() - def get_projects_for_user(self, user_id): session = self.get_session() self.get_user(user_id) diff --git a/keystone/identity/controllers.py b/keystone/identity/controllers.py index c34a25b637..8060e28f57 100644 --- a/keystone/identity/controllers.py +++ b/keystone/identity/controllers.py @@ -39,7 +39,7 @@ class Tenant(controller.V2Controller): context, context['query_string'].get('name')) self.assert_admin(context) - tenant_refs = self.identity_api.get_projects(context) + tenant_refs = self.identity_api.list_projects(context) for tenant_ref in tenant_refs: tenant_ref = self._filter_domain_id(tenant_ref) params = { diff --git a/keystone/identity/core.py b/keystone/identity/core.py index 9058730717..7810d3f425 100644 --- a/keystone/identity/core.py +++ b/keystone/identity/core.py @@ -119,23 +119,10 @@ class Driver(object): """ raise exception.NotImplemented() - def get_all_projects(self): - """FIXME(dolph): Lists all tenants in the system? I'm not sure how this - is different from get_projects, why get_projects isn't - documented as part of the driver, or why it's called - get_projects instead of list_projects (i.e. list_roles - and list_users)... - - :returns: a list of ... FIXME(dolph): tenant_refs or tenant_id's? - - """ - raise exception.NotImplemented() - def get_project_users(self, tenant_id): - """FIXME(dolph): Lists all users with a relationship to the specified - tenant? + """Lists all users with a relationship to the specified project. - :returns: a list of ... FIXME(dolph): user_refs or user_id's? + :returns: a list of user_refs or an empty set. :raises: keystone.exception.ProjectNotFound """ @@ -303,6 +290,14 @@ class Driver(object): """ raise exception.NotImplemented() + def list_user_projects(self, user_id): + """List all projects associated with a given user. + + :returns: a list of project_refs or an empty list. + + """ + raise exception.NotImplemented() + def get_project(self): """Get a project by ID. diff --git a/tests/test_backend.py b/tests/test_backend.py index 5270ad6dd5..172afbcce1 100644 --- a/tests/test_backend.py +++ b/tests/test_backend.py @@ -1397,12 +1397,6 @@ class IdentityTests(object): for test_role in default_fixtures.ROLES: self.assertTrue(x for x in roles if x['id'] == test_role['id']) - def test_get_projects(self): - tenants = self.identity_api.get_projects() - for test_project in default_fixtures.TENANTS: - self.assertTrue(x for x in tenants - if x['id'] == test_project['id']) - def test_delete_project_with_role_assignments(self): tenant = {'id': uuid.uuid4().hex, 'name': uuid.uuid4().hex, 'domain_id': DEFAULT_DOMAIN_ID} diff --git a/tests/test_backend_kvs.py b/tests/test_backend_kvs.py index a27aeb42ab..9a733ae2b3 100644 --- a/tests/test_backend_kvs.py +++ b/tests/test_backend_kvs.py @@ -34,18 +34,7 @@ class KvsIdentity(test.TestCase, test_backend.IdentityTests): self.load_fixtures(default_fixtures) def test_list_user_projects(self): - raise nose.exc.SkipTest('Blocked by bug 1119770') - - def test_list_projects(self): - raise nose.exc.SkipTest('Blocked by bug 1119770') - - def test_list_groups(self): - raise nose.exc.SkipTest('Blocked by bug 1119770') - - def test_list_domains(self): - raise nose.exc.SkipTest('Blocked by bug 1119770') - - def test_get_project_users(self): + # NOTE(chungg): not implemented raise nose.exc.SkipTest('Blocked by bug 1119770') diff --git a/tests/test_backend_ldap.py b/tests/test_backend_ldap.py index fc5aa567e0..8b7d0fca7d 100644 --- a/tests/test_backend_ldap.py +++ b/tests/test_backend_ldap.py @@ -45,17 +45,6 @@ class LDAPIdentity(test.TestCase, test_backend.IdentityTests): self.identity_api = identity_ldap.Identity() self.load_fixtures(default_fixtures) - def test_role_crud(self): - role = {'id': uuid.uuid4().hex, 'name': uuid.uuid4().hex} - self.identity_api.create_role(role['id'], role) - role_ref = self.identity_api.get_role(role['id']) - role_ref_dict = dict((x, role_ref[x]) for x in role_ref) - self.assertDictEqual(role_ref_dict, role) - self.identity_api.delete_role(role['id']) - self.assertRaises(exception.RoleNotFound, - self.identity_api.get_role, - role['id']) - def test_build_tree(self): """Regression test for building the tree names """ @@ -494,16 +483,13 @@ class LDAPIdentity(test.TestCase, test_backend.IdentityTests): raise nose.exc.SkipTest('Blocked by bug 1101287') def test_list_groups(self): - raise nose.exc.SkipTest('Blocked by bug 1122354') + raise nose.exc.SkipTest('Blocked by bug 1092187') def test_list_domains(self): - raise nose.exc.SkipTest('Blocked by bug 1122354') - - def test_list_projects(self): - raise nose.exc.SkipTest('Blocked by bug 1122354') + raise nose.exc.SkipTest('Blocked by bug 1101276') def test_list_user_projects(self): - raise nose.exc.SkipTest('Blocked by bug 1122354') + raise nose.exc.SkipTest('Blocked by bug 1101287') def test_get_project_users(self): - raise nose.exc.SkipTest('Blocked by bug 1122354') + raise nose.exc.SkipTest('Blocked by bug 1101287') diff --git a/tests/test_content_types.py b/tests/test_content_types.py index 73b2fae282..975f812871 100644 --- a/tests/test_content_types.py +++ b/tests/test_content_types.py @@ -509,7 +509,7 @@ class CoreApiTests(object): def test_invalid_parameter_error_response(self): token = self.get_scoped_token() bad_body = { - 'OS-KSADM:serviceBAD': { + 'OS-KSADM:service%s' % uuid.uuid4().hex: { 'name': uuid.uuid4().hex, 'type': uuid.uuid4().hex, },