Add iam.list_open_id_connect_providers

This commit is contained in:
gruebel 2019-10-18 21:12:44 +02:00
parent f4af9a1d54
commit cd8027ce9d
4 changed files with 68 additions and 2 deletions

View File

@ -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

View File

@ -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()

View File

@ -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 = """<ListEntitiesForPolicyResponse>
<ListEntitiesForPolicyResult>
@ -2038,3 +2044,19 @@ GET_OPEN_ID_CONNECT_PROVIDER_TEMPLATE = """<GetOpenIDConnectProviderResponse xml
<RequestId>2c91531b-4f65-11e4-aefa-bfd6aEXAMPLE</RequestId>
</ResponseMetadata>
</GetOpenIDConnectProviderResponse>"""
LIST_OPEN_ID_CONNECT_PROVIDERS_TEMPLATE = """<ListOpenIDConnectProvidersResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
<ListOpenIDConnectProvidersResult>
<OpenIDConnectProviderList>
{% for open_id_provider_arn in open_id_provider_arns %}
<member>
<Arn>{{ open_id_provider_arn }}</Arn>
</member>
{% endfor %}
</OpenIDConnectProviderList>
</ListOpenIDConnectProvidersResult>
<ResponseMetadata>
<RequestId>de2c0228-4f63-11e4-aefa-bfd6aEXAMPLE</RequestId>
</ResponseMetadata>
</ListOpenIDConnectProvidersResponse>"""

View File

@ -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
}
])