Add iam.delete_open_id_connect_provider

This commit is contained in:
gruebel 2019-10-18 20:51:22 +02:00
parent c492c5c228
commit f4af9a1d54
4 changed files with 47 additions and 3 deletions

View File

@ -3193,7 +3193,7 @@
- [ ] delete_group_policy - [ ] delete_group_policy
- [ ] delete_instance_profile - [ ] delete_instance_profile
- [X] delete_login_profile - [X] delete_login_profile
- [ ] delete_open_id_connect_provider - [X] delete_open_id_connect_provider
- [X] delete_policy - [X] delete_policy
- [X] delete_policy_version - [X] delete_policy_version
- [X] delete_role - [X] delete_role

View File

@ -1352,6 +1352,9 @@ class IAMBackend(BaseBackend):
self.open_id_providers[open_id_provider.arn] = open_id_provider self.open_id_providers[open_id_provider.arn] = open_id_provider
return open_id_provider return open_id_provider
def delete_open_id_connect_provider(self, arn):
self.open_id_providers.pop(arn, None)
def get_open_id_connect_provider(self, arn): def get_open_id_connect_provider(self, arn):
open_id_provider = self.open_id_providers.get(arn) open_id_provider = self.open_id_providers.get(arn)

View File

@ -765,6 +765,14 @@ class IamResponse(BaseResponse):
template = self.response_template(CREATE_OPEN_ID_CONNECT_PROVIDER_TEMPLATE) template = self.response_template(CREATE_OPEN_ID_CONNECT_PROVIDER_TEMPLATE)
return template.render(open_id_provider=open_id_provider) return template.render(open_id_provider=open_id_provider)
def delete_open_id_connect_provider(self):
open_id_provider_arn = self._get_param('OpenIDConnectProviderArn')
iam_backend.delete_open_id_connect_provider(open_id_provider_arn)
template = self.response_template(DELETE_OPEN_ID_CONNECT_PROVIDER_TEMPLATE)
return template.render()
def get_open_id_connect_provider(self): def get_open_id_connect_provider(self):
open_id_provider_arn = self._get_param('OpenIDConnectProviderArn') open_id_provider_arn = self._get_param('OpenIDConnectProviderArn')
@ -2004,6 +2012,13 @@ CREATE_OPEN_ID_CONNECT_PROVIDER_TEMPLATE = """<CreateOpenIDConnectProviderRespon
</CreateOpenIDConnectProviderResponse>""" </CreateOpenIDConnectProviderResponse>"""
DELETE_OPEN_ID_CONNECT_PROVIDER_TEMPLATE = """<DeleteOpenIDConnectProviderResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
<ResponseMetadata>
<RequestId>b5e49e29-4f64-11e4-aefa-bfd6aEXAMPLE</RequestId>
</ResponseMetadata>
</DeleteOpenIDConnectProviderResponse>"""
GET_OPEN_ID_CONNECT_PROVIDER_TEMPLATE = """<GetOpenIDConnectProviderResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/"> GET_OPEN_ID_CONNECT_PROVIDER_TEMPLATE = """<GetOpenIDConnectProviderResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
<GetOpenIDConnectProviderResult> <GetOpenIDConnectProviderResult>
<ThumbprintList> <ThumbprintList>

View File

@ -1699,6 +1699,32 @@ def test_create_open_id_connect_provider_errors():
) )
@mock_iam
def test_delete_open_id_connect_provider():
client = boto3.client('iam', region_name='us-east-1')
response = client.create_open_id_connect_provider(
Url='https://example.com',
ThumbprintList=[]
)
open_id_arn = response['OpenIDConnectProviderArn']
client.delete_open_id_connect_provider(
OpenIDConnectProviderArn=open_id_arn
)
client.get_open_id_connect_provider.when.called_with(
OpenIDConnectProviderArn=open_id_arn
).should.throw(
ClientError,
'OpenIDConnect Provider not found for arn {}'.format(open_id_arn)
)
# deleting a non existing provider should be successful
client.delete_open_id_connect_provider(
OpenIDConnectProviderArn=open_id_arn
)
@freeze_time('2019-01-01 00:00:00') @freeze_time('2019-01-01 00:00:00')
@mock_iam @mock_iam
def test_get_open_id_connect_provider(): def test_get_open_id_connect_provider():
@ -1730,7 +1756,7 @@ def test_get_open_id_connect_provider():
@mock_iam @mock_iam
def test_get_open_id_connect_provider_errors(): def test_get_open_id_connect_provider_errors():
client = boto3.client('iam', region_name = 'us-east-1') client = boto3.client('iam', region_name='us-east-1')
response = client.create_open_id_connect_provider( response = client.create_open_id_connect_provider(
Url='https://example.com', Url='https://example.com',
ThumbprintList=[ ThumbprintList=[
@ -1743,7 +1769,7 @@ def test_get_open_id_connect_provider_errors():
open_id_arn = response['OpenIDConnectProviderArn'] open_id_arn = response['OpenIDConnectProviderArn']
client.get_open_id_connect_provider.when.called_with( client.get_open_id_connect_provider.when.called_with(
OpenIDConnectProviderArn = open_id_arn + '-not-existing' OpenIDConnectProviderArn=open_id_arn + '-not-existing'
).should.throw( ).should.throw(
ClientError, ClientError,
'OpenIDConnect Provider not found for arn {}'.format(open_id_arn + '-not-existing') 'OpenIDConnect Provider not found for arn {}'.format(open_id_arn + '-not-existing')