From 030e500f75a7be154cbc3c4e2ee670a7f1be6f04 Mon Sep 17 00:00:00 2001 From: Tom Cocozzello Date: Thu, 21 Jan 2016 10:12:50 -0600 Subject: [PATCH] Fix nits in include names patch Some comments that needed to be addressed in [0] - Add a negative test - Fix reno note [0] I0a1cc986b8a35aeafe567e5e7fee6eeb848ae113 Change-Id: Ibbdf2c321a9b2c8c8b7955521536a992bc475aba --- keystone/tests/unit/test_backend.py | 40 +++++++++++++++++++ ...ole_assignment_names-33aedc1e521230b6.yaml | 5 ++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/keystone/tests/unit/test_backend.py b/keystone/tests/unit/test_backend.py index aed80fa0d5..a73746d5fe 100644 --- a/keystone/tests/unit/test_backend.py +++ b/keystone/tests/unit/test_backend.py @@ -4201,6 +4201,46 @@ class IdentityTests(AssignmentTestHelperMixin): self.assertEqual(new_role['name'], first_asgmt_dmn['role_name']) + def test_list_role_assignment_does_not_contain_names(self): + """Test names are not included with list role assignments. + + Scenario: + - names are NOT included by default + - names are NOT included when include_names=False + + """ + def assert_does_not_contain_names(assignment): + first_asgmt_prj = assignment[0] + self.assertNotIn('project_name', first_asgmt_prj) + self.assertNotIn('project_domain_id', first_asgmt_prj) + self.assertNotIn('user_name', first_asgmt_prj) + self.assertNotIn('user_domain_id', first_asgmt_prj) + self.assertNotIn('role_name', first_asgmt_prj) + + # Create Refs + new_role = unit.new_role_ref() + new_domain = self._get_domain_fixture() + new_user = unit.new_user_ref(domain_id=new_domain['id']) + new_project = unit.new_project_ref(domain_id=new_domain['id']) + # Create entities + new_role = self.role_api.create_role(new_role['id'], new_role) + new_user = self.identity_api.create_user(new_user) + self.resource_api.create_project(new_project['id'], new_project) + self.assignment_api.create_grant(user_id=new_user['id'], + project_id=new_project['id'], + role_id=new_role['id']) + # Get the created assignments with NO include_names flag + role_assign_without_names = self.assignment_api.list_role_assignments( + user_id=new_user['id'], + project_id=new_project['id']) + assert_does_not_contain_names(role_assign_without_names) + # Get the created assignments with include_names=False + role_assign_without_names = self.assignment_api.list_role_assignments( + user_id=new_user['id'], + project_id=new_project['id'], + include_names=False) + assert_does_not_contain_names(role_assign_without_names) + class TokenTests(object): def _create_token_id(self): diff --git a/releasenotes/notes/list_role_assignment_names-33aedc1e521230b6.yaml b/releasenotes/notes/list_role_assignment_names-33aedc1e521230b6.yaml index fd1fe665ce..267ece711c 100644 --- a/releasenotes/notes/list_role_assignment_names-33aedc1e521230b6.yaml +++ b/releasenotes/notes/list_role_assignment_names-33aedc1e521230b6.yaml @@ -2,5 +2,6 @@ features: - > [`bug 1479569 `_] - Names have been added to list role assignments, rather than returning - just the internal ids of the objects the names are also returned. \ No newline at end of file + Names have been added to list role assignments + (GET /role_assignments?include_names=True), rather than returning + just the internal IDs of the objects the names are also returned.