2018-03-28 19:40:42 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import boto3
|
2018-04-03 21:08:20 +00:00
|
|
|
|
|
|
|
from moto import mock_cognitoidentity
|
2018-03-28 19:40:42 +00:00
|
|
|
import sure # noqa
|
|
|
|
|
2018-04-03 18:38:59 +00:00
|
|
|
|
|
|
|
@mock_cognitoidentity
|
|
|
|
def test_create_identity_pool():
|
|
|
|
conn = boto3.client('cognito-identity', 'us-west-2')
|
|
|
|
|
|
|
|
result = conn.create_identity_pool(IdentityPoolName='TestPool',
|
2018-04-03 21:08:20 +00:00
|
|
|
AllowUnauthenticatedIdentities=False,
|
|
|
|
SupportedLoginProviders={'graph.facebook.com': '123456789012345'},
|
2018-04-03 18:38:59 +00:00
|
|
|
DeveloperProviderName='devname',
|
2018-04-03 21:08:20 +00:00
|
|
|
OpenIdConnectProviderARNs=['arn:aws:rds:eu-west-2:123456789012:db:mysql-db'],
|
2018-04-03 18:38:59 +00:00
|
|
|
CognitoIdentityProviders=[
|
|
|
|
{
|
|
|
|
'ProviderName': 'testprovider',
|
|
|
|
'ClientId': 'CLIENT12345',
|
|
|
|
'ServerSideTokenCheck': True
|
2018-03-28 19:40:42 +00:00
|
|
|
},
|
2018-04-03 18:38:59 +00:00
|
|
|
],
|
2018-04-03 21:08:20 +00:00
|
|
|
SamlProviderARNs=['arn:aws:rds:eu-west-2:123456789012:db:mysql-db'])
|
2018-04-03 18:38:59 +00:00
|
|
|
assert result['IdentityPoolId'] != ''
|
|
|
|
|
2018-04-03 21:08:20 +00:00
|
|
|
|
2018-04-03 18:38:59 +00:00
|
|
|
@mock_cognitoidentity
|
|
|
|
def test_get_id():
|
|
|
|
conn = boto3.client('cognito-identity', 'us-west-2')
|
|
|
|
result = conn.get_id(AccountId='someaccount',
|
|
|
|
IdentityPoolId='us-west-2:12345',
|
|
|
|
Logins={
|
2018-04-03 21:08:20 +00:00
|
|
|
'someurl': '12345'
|
2018-04-03 18:38:59 +00:00
|
|
|
})
|
2018-04-03 21:08:20 +00:00
|
|
|
print(result)
|
2018-04-03 18:38:59 +00:00
|
|
|
assert result['IdentityId'].startswith('us-west-2')
|
|
|
|
|
2018-04-03 21:08:20 +00:00
|
|
|
|
2018-04-03 18:38:59 +00:00
|
|
|
@mock_cognitoidentity
|
|
|
|
def test_get_credentials_for_identity():
|
|
|
|
conn = boto3.client('cognito-identity', 'us-west-2')
|
|
|
|
result = conn.get_credentials_for_identity(IdentityId='12345')
|
|
|
|
assert result['IdentityId'] == '12345'
|
|
|
|
|
2018-04-03 21:08:20 +00:00
|
|
|
|
2018-04-03 18:38:59 +00:00
|
|
|
@mock_cognitoidentity
|
|
|
|
def test_get_open_id_token_for_developer_identity():
|
|
|
|
conn = boto3.client('cognito-identity', 'us-west-2')
|
|
|
|
result = conn.get_open_id_token_for_developer_identity(
|
|
|
|
IdentityPoolId='us-west-2:12345',
|
|
|
|
IdentityId='12345',
|
|
|
|
Logins={
|
|
|
|
'someurl': '12345'
|
|
|
|
},
|
|
|
|
TokenDuration=123
|
|
|
|
)
|
|
|
|
assert result['IdentityId'] == '12345'
|