Merge "Creating parameter to list inherited role assignments"
This commit is contained in:
@@ -177,6 +177,21 @@ class RoleAssignmentsTests(utils.TestCase, utils.CrudTests):
|
||||
kwargs = {'role.id': self.TEST_ROLE_ID}
|
||||
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):
|
||||
# Should only accept either domain or project, never both
|
||||
self.assertRaises(exceptions.ValidationError,
|
||||
|
@@ -47,7 +47,7 @@ class RoleAssignmentManager(base.CrudManager):
|
||||
raise exceptions.ValidationError(msg)
|
||||
|
||||
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.
|
||||
|
||||
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 boolean effective: return effective role
|
||||
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)
|
||||
@@ -84,6 +87,9 @@ class RoleAssignmentManager(base.CrudManager):
|
||||
query_params['role.id'] = base.getid(role)
|
||||
if 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)
|
||||
|
||||
|
Reference in New Issue
Block a user