diff --git a/IMPLEMENTATION_COVERAGE.md b/IMPLEMENTATION_COVERAGE.md index e91376eda..8ccfb2ccf 100644 --- a/IMPLEMENTATION_COVERAGE.md +++ b/IMPLEMENTATION_COVERAGE.md @@ -3193,7 +3193,7 @@ - [ ] delete_group_policy - [ ] delete_instance_profile - [X] delete_login_profile -- [ ] delete_open_id_connect_provider +- [X] delete_open_id_connect_provider - [X] delete_policy - [X] delete_policy_version - [X] delete_role diff --git a/moto/iam/models.py b/moto/iam/models.py index b95c37df7..6c790c15f 100644 --- a/moto/iam/models.py +++ b/moto/iam/models.py @@ -1352,6 +1352,9 @@ class IAMBackend(BaseBackend): self.open_id_providers[open_id_provider.arn] = 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): open_id_provider = self.open_id_providers.get(arn) diff --git a/moto/iam/responses.py b/moto/iam/responses.py index 06ad7b7ce..819f0e649 100644 --- a/moto/iam/responses.py +++ b/moto/iam/responses.py @@ -765,6 +765,14 @@ class IamResponse(BaseResponse): template = self.response_template(CREATE_OPEN_ID_CONNECT_PROVIDER_TEMPLATE) 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): open_id_provider_arn = self._get_param('OpenIDConnectProviderArn') @@ -2004,6 +2012,13 @@ CREATE_OPEN_ID_CONNECT_PROVIDER_TEMPLATE = """""" +DELETE_OPEN_ID_CONNECT_PROVIDER_TEMPLATE = """ + + b5e49e29-4f64-11e4-aefa-bfd6aEXAMPLE + +""" + + GET_OPEN_ID_CONNECT_PROVIDER_TEMPLATE = """ diff --git a/tests/test_iam/test_iam.py b/tests/test_iam/test_iam.py index ea0434bff..cffa00a37 100644 --- a/tests/test_iam/test_iam.py +++ b/tests/test_iam/test_iam.py @@ -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') @mock_iam def test_get_open_id_connect_provider(): @@ -1730,7 +1756,7 @@ def test_get_open_id_connect_provider(): @mock_iam 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( Url='https://example.com', ThumbprintList=[ @@ -1743,7 +1769,7 @@ def test_get_open_id_connect_provider_errors(): open_id_arn = response['OpenIDConnectProviderArn'] client.get_open_id_connect_provider.when.called_with( - OpenIDConnectProviderArn = open_id_arn + '-not-existing' + OpenIDConnectProviderArn=open_id_arn + '-not-existing' ).should.throw( ClientError, 'OpenIDConnect Provider not found for arn {}'.format(open_id_arn + '-not-existing')