Add iam.delete_virtual_mfa_device
This commit is contained in:
parent
9671730f16
commit
c80135a6db
@ -3163,7 +3163,7 @@
|
|||||||
- [ ] describe_events
|
- [ ] describe_events
|
||||||
|
|
||||||
## iam
|
## iam
|
||||||
59% implemented
|
60% implemented
|
||||||
- [ ] add_client_id_to_open_id_connect_provider
|
- [ ] add_client_id_to_open_id_connect_provider
|
||||||
- [X] add_role_to_instance_profile
|
- [X] add_role_to_instance_profile
|
||||||
- [X] add_user_to_group
|
- [X] add_user_to_group
|
||||||
@ -3208,7 +3208,7 @@
|
|||||||
- [X] delete_user
|
- [X] delete_user
|
||||||
- [ ] delete_user_permissions_boundary
|
- [ ] delete_user_permissions_boundary
|
||||||
- [X] delete_user_policy
|
- [X] delete_user_policy
|
||||||
- [ ] delete_virtual_mfa_device
|
- [X] delete_virtual_mfa_device
|
||||||
- [X] detach_group_policy
|
- [X] detach_group_policy
|
||||||
- [X] detach_role_policy
|
- [X] detach_role_policy
|
||||||
- [X] detach_user_policy
|
- [X] detach_user_policy
|
||||||
|
@ -1295,6 +1295,12 @@ class IAMBackend(BaseBackend):
|
|||||||
self.virtual_mfa_devices[device.serial_number] = device
|
self.virtual_mfa_devices[device.serial_number] = device
|
||||||
return device
|
return device
|
||||||
|
|
||||||
|
def delete_virtual_mfa_device(self, serial_number):
|
||||||
|
device = self.virtual_mfa_devices.pop(serial_number, None)
|
||||||
|
|
||||||
|
if not device:
|
||||||
|
raise IAMNotFoundException('VirtualMFADevice with serial number {0} doesn\'t exist.'.format(serial_number))
|
||||||
|
|
||||||
def delete_user(self, user_name):
|
def delete_user(self, user_name):
|
||||||
try:
|
try:
|
||||||
del self.users[user_name]
|
del self.users[user_name]
|
||||||
|
@ -607,6 +607,14 @@ class IamResponse(BaseResponse):
|
|||||||
template = self.response_template(CREATE_VIRTUAL_MFA_DEVICE_TEMPLATE)
|
template = self.response_template(CREATE_VIRTUAL_MFA_DEVICE_TEMPLATE)
|
||||||
return template.render(device=virtual_mfa_device)
|
return template.render(device=virtual_mfa_device)
|
||||||
|
|
||||||
|
def delete_virtual_mfa_device(self):
|
||||||
|
serial_number = self._get_param('SerialNumber')
|
||||||
|
|
||||||
|
iam_backend.delete_virtual_mfa_device(serial_number)
|
||||||
|
|
||||||
|
template = self.response_template(DELETE_VIRTUAL_MFA_DEVICE_TEMPLATE)
|
||||||
|
return template.render()
|
||||||
|
|
||||||
def delete_user(self):
|
def delete_user(self):
|
||||||
user_name = self._get_param('UserName')
|
user_name = self._get_param('UserName')
|
||||||
iam_backend.delete_user(user_name)
|
iam_backend.delete_user(user_name)
|
||||||
@ -1697,6 +1705,13 @@ CREATE_VIRTUAL_MFA_DEVICE_TEMPLATE = """<CreateVirtualMFADeviceResponse xmlns="h
|
|||||||
</CreateVirtualMFADeviceResponse>"""
|
</CreateVirtualMFADeviceResponse>"""
|
||||||
|
|
||||||
|
|
||||||
|
DELETE_VIRTUAL_MFA_DEVICE_TEMPLATE = """<DeleteVirtualMFADeviceResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
|
||||||
|
<ResponseMetadata>
|
||||||
|
<RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId>
|
||||||
|
</ResponseMetadata>
|
||||||
|
</DeleteVirtualMFADeviceResponse>"""
|
||||||
|
|
||||||
|
|
||||||
LIST_ACCOUNT_ALIASES_TEMPLATE = """<ListAccountAliasesResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
|
LIST_ACCOUNT_ALIASES_TEMPLATE = """<ListAccountAliasesResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
|
||||||
<ListAccountAliasesResult>
|
<ListAccountAliasesResult>
|
||||||
<IsTruncated>false</IsTruncated>
|
<IsTruncated>false</IsTruncated>
|
||||||
|
@ -800,6 +800,32 @@ def test_create_virtual_mfa_device_errors():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@mock_iam
|
||||||
|
def test_delete_virtual_mfa_device():
|
||||||
|
client = boto3.client('iam', region_name='us-east-1')
|
||||||
|
response = client.create_virtual_mfa_device(
|
||||||
|
VirtualMFADeviceName='test-device'
|
||||||
|
)
|
||||||
|
serial_number = response['VirtualMFADevice']['SerialNumber']
|
||||||
|
|
||||||
|
client.delete_virtual_mfa_device(
|
||||||
|
SerialNumber=serial_number
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@mock_iam
|
||||||
|
def test_delete_virtual_mfa_device_errors():
|
||||||
|
client = boto3.client('iam', region_name='us-east-1')
|
||||||
|
|
||||||
|
serial_number = 'arn:aws:iam::123456789012:mfa/not-existing'
|
||||||
|
client.delete_virtual_mfa_device.when.called_with(
|
||||||
|
SerialNumber=serial_number
|
||||||
|
).should.throw(
|
||||||
|
ClientError,
|
||||||
|
'VirtualMFADevice with serial number {0} doesn\'t exist.'.format(serial_number)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@mock_iam_deprecated()
|
@mock_iam_deprecated()
|
||||||
def test_delete_user_deprecated():
|
def test_delete_user_deprecated():
|
||||||
conn = boto.connect_iam()
|
conn = boto.connect_iam()
|
||||||
|
Loading…
Reference in New Issue
Block a user