FIX : IAM - Added support for pathPrefix in list_users_function (#3180)
* FIX:IAM-Added support for pathPrefix in list_users_function * removed changes for roles * Added test for non decorator * changed filter function Co-authored-by: usmankb <usman@krazybee.com>
This commit is contained in:
parent
bc1674cb19
commit
1db42fb865
3 changed files with 14 additions and 1 deletions
|
|
@ -946,6 +946,10 @@ class AccountSummary(BaseModel):
|
|||
return len(self._iam_backend.users)
|
||||
|
||||
|
||||
def filter_items_with_path_prefix(path_prefix, items):
|
||||
return [role for role in items if role.path.startswith(path_prefix)]
|
||||
|
||||
|
||||
class IAMBackend(BaseBackend):
|
||||
def __init__(self):
|
||||
self.instance_profiles = {}
|
||||
|
|
@ -1490,7 +1494,11 @@ class IAMBackend(BaseBackend):
|
|||
def list_users(self, path_prefix, marker, max_items):
|
||||
users = None
|
||||
try:
|
||||
|
||||
users = self.users.values()
|
||||
if path_prefix:
|
||||
users = filter_items_with_path_prefix(path_prefix, users)
|
||||
|
||||
except KeyError:
|
||||
raise IAMNotFoundException(
|
||||
"Users {0}, {1}, {2} not found".format(path_prefix, marker, max_items)
|
||||
|
|
|
|||
|
|
@ -337,7 +337,6 @@ class IamResponse(BaseResponse):
|
|||
|
||||
def list_roles(self):
|
||||
roles = iam_backend.get_roles()
|
||||
|
||||
template = self.response_template(LIST_ROLES_TEMPLATE)
|
||||
return template.render(roles=roles)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue