cognito-identity: Support for list identity pools (#7055)
This commit is contained in:
parent
7c83ca157f
commit
0cce33695b
@ -174,5 +174,17 @@ class CognitoIdentityBackend(BaseBackend):
|
||||
"""
|
||||
return json.dumps(self.pools_identities[identity_pool_id])
|
||||
|
||||
def list_identity_pools(self) -> str:
|
||||
"""
|
||||
The MaxResults-parameter has not yet been implemented
|
||||
"""
|
||||
return json.dumps(
|
||||
{
|
||||
"IdentityPools": [
|
||||
json.loads(pool.to_json()) for pool in self.identity_pools.values()
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
cognitoidentity_backends = BackendDict(CognitoIdentityBackend, "cognito-identity")
|
||||
|
@ -80,3 +80,6 @@ class CognitoIdentityResponse(BaseResponse):
|
||||
return self.backend.list_identities(
|
||||
self._get_param("IdentityPoolId") or get_random_identity_id(self.region)
|
||||
)
|
||||
|
||||
def list_identity_pools(self) -> str:
|
||||
return self.backend.list_identity_pools()
|
||||
|
@ -240,3 +240,15 @@ def test_list_identities():
|
||||
identities = conn.list_identities(IdentityPoolId=identity_pool_id, MaxResults=123)
|
||||
assert "IdentityPoolId" in identities and "Identities" in identities
|
||||
assert identity_id in [x["IdentityId"] for x in identities["Identities"]]
|
||||
|
||||
|
||||
@mock_cognitoidentity
|
||||
def test_list_identity_pools():
|
||||
conn = boto3.client("cognito-identity", "us-west-2")
|
||||
identity_pool_data = conn.create_identity_pool(
|
||||
IdentityPoolName="test_identity_pool", AllowUnauthenticatedIdentities=True
|
||||
)
|
||||
identity_pool_id = identity_pool_data["IdentityPoolId"]
|
||||
identity_data = conn.list_identity_pools(MaxResults=10)
|
||||
assert identity_pool_id == identity_data["IdentityPools"][0]["IdentityPoolId"]
|
||||
assert "test_identity_pool" == identity_data["IdentityPools"][0]["IdentityPoolName"]
|
||||
|
Loading…
Reference in New Issue
Block a user