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:
usmangani1 2020-07-27 20:02:41 +05:30 committed by GitHub
commit 1db42fb865
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View file

@ -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)

View file

@ -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)