Add iam.delete_account_password_policy

This commit is contained in:
gruebel 2019-11-01 07:00:50 +01:00
parent 65fa8f1a1b
commit 89c43820c9
4 changed files with 47 additions and 1 deletions

View File

@ -3286,7 +3286,7 @@
- [X] deactivate_mfa_device - [X] deactivate_mfa_device
- [X] delete_access_key - [X] delete_access_key
- [X] delete_account_alias - [X] delete_account_alias
- [ ] delete_account_password_policy - [X] delete_account_password_policy
- [ ] delete_group - [ ] delete_group
- [ ] delete_group_policy - [ ] delete_group_policy
- [ ] delete_instance_profile - [ ] delete_instance_profile

View File

@ -1678,5 +1678,11 @@ class IAMBackend(BaseBackend):
return self.account_password_policy return self.account_password_policy
def delete_account_password_policy(self):
if not self.account_password_policy:
raise NoSuchEntity('The account policy with name PasswordPolicy cannot be found.')
self.account_password_policy = None
iam_backend = IAMBackend() iam_backend = IAMBackend()

View File

@ -863,6 +863,12 @@ class IamResponse(BaseResponse):
template = self.response_template(GET_ACCOUNT_PASSWORD_POLICY_TEMPLATE) template = self.response_template(GET_ACCOUNT_PASSWORD_POLICY_TEMPLATE)
return template.render(password_policy=account_password_policy) return template.render(password_policy=account_password_policy)
def delete_account_password_policy(self):
iam_backend.delete_account_password_policy()
template = self.response_template(DELETE_ACCOUNT_PASSWORD_POLICY_TEMPLATE)
return template.render()
LIST_ENTITIES_FOR_POLICY_TEMPLATE = """<ListEntitiesForPolicyResponse> LIST_ENTITIES_FOR_POLICY_TEMPLATE = """<ListEntitiesForPolicyResponse>
<ListEntitiesForPolicyResult> <ListEntitiesForPolicyResult>
@ -2229,3 +2235,10 @@ GET_ACCOUNT_PASSWORD_POLICY_TEMPLATE = """<GetAccountPasswordPolicyResponse xmln
<RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId> <RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId>
</ResponseMetadata> </ResponseMetadata>
</GetAccountPasswordPolicyResponse>""" </GetAccountPasswordPolicyResponse>"""
DELETE_ACCOUNT_PASSWORD_POLICY_TEMPLATE = """<DeleteAccountPasswordPolicyResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
<ResponseMetadata>
<RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId>
</ResponseMetadata>
</DeleteAccountPasswordPolicyResponse>"""

View File

@ -2274,3 +2274,30 @@ def test_get_account_password_policy_errors():
ClientError, ClientError,
'The Password Policy with domain name 123456789012 cannot be found.' 'The Password Policy with domain name 123456789012 cannot be found.'
) )
@mock_iam
def test_delete_account_password_policy():
client = boto3.client('iam', region_name='us-east-1')
client.update_account_password_policy()
response = client.get_account_password_policy()
response.should.have.key('PasswordPolicy').which.should.be.a(dict)
client.delete_account_password_policy()
client.get_account_password_policy.when.called_with().should.throw(
ClientError,
'The Password Policy with domain name 123456789012 cannot be found.'
)
@mock_iam
def test_delete_account_password_policy_errors():
client = boto3.client('iam', region_name='us-east-1')
client.delete_account_password_policy.when.called_with().should.throw(
ClientError,
'The account policy with name PasswordPolicy cannot be found.'
)