Merge "Creating parameter to list inherited role assignments"

This commit is contained in:
Jenkins
2015-03-10 20:53:17 +00:00
committed by Gerrit Code Review
2 changed files with 22 additions and 1 deletions

View File

@@ -177,6 +177,21 @@ class RoleAssignmentsTests(utils.TestCase, utils.CrudTests):
kwargs = {'role.id': self.TEST_ROLE_ID} kwargs = {'role.id': self.TEST_ROLE_ID}
self.assertQueryStringContains(**kwargs) self.assertQueryStringContains(**kwargs)
def test_role_assignments_inherited_list(self):
ref_list = self.TEST_ALL_RESPONSE_LIST
self.stub_entity('GET',
[self.collection_key,
'?scope.OS-INHERIT:inherited_to=projects'],
entity=ref_list
)
returned_list = self.manager.list(
os_inherit_extension_inherited_to='projects')
self._assert_returned_list(ref_list, returned_list)
query_string = 'scope.OS-INHERIT:inherited_to=projects'
self.assertQueryStringIs(query_string)
def test_domain_and_project_list(self): def test_domain_and_project_list(self):
# Should only accept either domain or project, never both # Should only accept either domain or project, never both
self.assertRaises(exceptions.ValidationError, self.assertRaises(exceptions.ValidationError,

View File

@@ -47,7 +47,7 @@ class RoleAssignmentManager(base.CrudManager):
raise exceptions.ValidationError(msg) raise exceptions.ValidationError(msg)
def list(self, user=None, group=None, project=None, domain=None, role=None, def list(self, user=None, group=None, project=None, domain=None, role=None,
effective=False): effective=False, os_inherit_extension_inherited_to=None):
"""Lists role assignments. """Lists role assignments.
If no arguments are provided, all role assignments in the If no arguments are provided, all role assignments in the
@@ -66,6 +66,9 @@ class RoleAssignmentManager(base.CrudManager):
:param role: Role to be used as query filter. (optional) :param role: Role to be used as query filter. (optional)
:param boolean effective: return effective role :param boolean effective: return effective role
assignments. (optional) assignments. (optional)
:param string os_inherit_extension_inherited_to:
return inherited role assignments for either 'projects' or
'domains'. (optional)
""" """
self._check_not_user_and_group(user, group) self._check_not_user_and_group(user, group)
@@ -84,6 +87,9 @@ class RoleAssignmentManager(base.CrudManager):
query_params['role.id'] = base.getid(role) query_params['role.id'] = base.getid(role)
if effective: if effective:
query_params['effective'] = effective query_params['effective'] = effective
if os_inherit_extension_inherited_to:
query_params['scope.OS-INHERIT:inherited_to'] = (
os_inherit_extension_inherited_to)
return super(RoleAssignmentManager, self).list(**query_params) return super(RoleAssignmentManager, self).list(**query_params)