diff --git a/IMPLEMENTATION_COVERAGE.md b/IMPLEMENTATION_COVERAGE.md index 8ccfb2ccf..284f4d68a 100644 --- a/IMPLEMENTATION_COVERAGE.md +++ b/IMPLEMENTATION_COVERAGE.md @@ -3163,7 +3163,7 @@ - [ ] describe_events ## iam -56% implemented +57% implemented - [ ] add_client_id_to_open_id_connect_provider - [X] add_role_to_instance_profile - [X] add_user_to_group @@ -3253,7 +3253,7 @@ - [ ] list_instance_profiles - [ ] list_instance_profiles_for_role - [X] list_mfa_devices -- [ ] list_open_id_connect_providers +- [X] list_open_id_connect_providers - [X] list_policies - [ ] list_policies_granting_service_access - [X] list_policy_versions diff --git a/moto/iam/models.py b/moto/iam/models.py index 6c790c15f..ba7d0ac82 100644 --- a/moto/iam/models.py +++ b/moto/iam/models.py @@ -1363,5 +1363,8 @@ class IAMBackend(BaseBackend): return open_id_provider + def list_open_id_connect_providers(self): + return list(self.open_id_providers.keys()) + iam_backend = IAMBackend() diff --git a/moto/iam/responses.py b/moto/iam/responses.py index 819f0e649..1c00d211c 100644 --- a/moto/iam/responses.py +++ b/moto/iam/responses.py @@ -781,6 +781,12 @@ class IamResponse(BaseResponse): template = self.response_template(GET_OPEN_ID_CONNECT_PROVIDER_TEMPLATE) return template.render(open_id_provider=open_id_provider) + def list_open_id_connect_providers(self): + open_id_provider_arns = iam_backend.list_open_id_connect_providers() + + template = self.response_template(LIST_OPEN_ID_CONNECT_PROVIDERS_TEMPLATE) + return template.render(open_id_provider_arns=open_id_provider_arns) + LIST_ENTITIES_FOR_POLICY_TEMPLATE = """ @@ -2038,3 +2044,19 @@ GET_OPEN_ID_CONNECT_PROVIDER_TEMPLATE = """2c91531b-4f65-11e4-aefa-bfd6aEXAMPLE """ + + +LIST_OPEN_ID_CONNECT_PROVIDERS_TEMPLATE = """ + + + {% for open_id_provider_arn in open_id_provider_arns %} + + {{ open_id_provider_arn }} + + {% endfor %} + + + + de2c0228-4f63-11e4-aefa-bfd6aEXAMPLE + +""" diff --git a/tests/test_iam/test_iam.py b/tests/test_iam/test_iam.py index cffa00a37..f87af0d16 100644 --- a/tests/test_iam/test_iam.py +++ b/tests/test_iam/test_iam.py @@ -1774,3 +1774,44 @@ def test_get_open_id_connect_provider_errors(): ClientError, 'OpenIDConnect Provider not found for arn {}'.format(open_id_arn + '-not-existing') ) + + +@mock_iam +def test_list_open_id_connect_providers(): + client = boto3.client('iam', region_name='us-east-1') + response = client.create_open_id_connect_provider( + Url='https://example.com', + ThumbprintList=[] + ) + open_id_arn_1 = response['OpenIDConnectProviderArn'] + + response = client.create_open_id_connect_provider( + Url='http://example.org', + ThumbprintList=[ + 'b' * 40 + ], + ClientIDList=[ + 'b' + ] + ) + open_id_arn_2 = response['OpenIDConnectProviderArn'] + + response = client.create_open_id_connect_provider( + Url='http://example.org/oidc', + ThumbprintList=[] + ) + open_id_arn_3 = response['OpenIDConnectProviderArn'] + + response = client.list_open_id_connect_providers() + + response['OpenIDConnectProviderList'].should.equal([ + { + 'Arn': open_id_arn_1 + }, + { + 'Arn': open_id_arn_2 + }, + { + 'Arn': open_id_arn_3 + } + ])