Add support for login profile deletion (#768)
* Add support for delete_login_profile. Mock deletion of login profile. Set password to none. Add tests to cover new endpoint. * Fix typo in create_login_profile response. Change CreateUserResult to CreateLoginProfileResult in the CREATE_LOGIN_PROFILE_TEMPLATE. Caused KeyError when using boto3. Add test to cover boto3 in addition to boto.
This commit is contained in:
parent
71c1fbadbe
commit
fa3663c610
3 changed files with 40 additions and 2 deletions
|
|
@ -604,6 +604,12 @@ class IAMBackend(BaseBackend):
|
|||
raise IAMConflictException("User {0} already has password".format(user_name))
|
||||
user.password = password
|
||||
|
||||
def delete_login_profile(self, user_name):
|
||||
user = self.get_user(user_name)
|
||||
if not user.password:
|
||||
raise IAMNotFoundException("Login profile for {0} not found".format(user_name))
|
||||
user.password = None
|
||||
|
||||
def add_user_to_group(self, group_name, user_name):
|
||||
user = self.get_user(user_name)
|
||||
group = self.get_group(group_name)
|
||||
|
|
|
|||
|
|
@ -289,6 +289,12 @@ class IamResponse(BaseResponse):
|
|||
template = self.response_template(GENERIC_EMPTY_TEMPLATE)
|
||||
return template.render(name='DeleteUser')
|
||||
|
||||
def delete_login_profile(self):
|
||||
user_name = self._get_param('UserName')
|
||||
iam_backend.delete_login_profile(user_name)
|
||||
template = self.response_template(GENERIC_EMPTY_TEMPLATE)
|
||||
return template.render(name='DeleteLoginProfile')
|
||||
|
||||
def generate_credential_report(self):
|
||||
if iam_backend.report_generated():
|
||||
template = self.response_template(CREDENTIAL_REPORT_GENERATED)
|
||||
|
|
@ -730,12 +736,12 @@ LIST_USERS_TEMPLATE = """<{{ action }}UsersResponse>
|
|||
|
||||
CREATE_LOGIN_PROFILE_TEMPLATE = """
|
||||
<CreateLoginProfileResponse>
|
||||
<CreateUserResult>
|
||||
<CreateLoginProfileResult>
|
||||
<LoginProfile>
|
||||
<UserName>{{ user_name }}</UserName>
|
||||
<CreateDate>2011-09-19T23:00:56Z</CreateDate>
|
||||
</LoginProfile>
|
||||
</CreateUserResult>
|
||||
</CreateLoginProfileResult>
|
||||
<ResponseMetadata>
|
||||
<RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId>
|
||||
</ResponseMetadata>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue