diff --git a/moto/cognitoidentity/models.py b/moto/cognitoidentity/models.py index d326b7a4a..d7ed596b6 100644 --- a/moto/cognitoidentity/models.py +++ b/moto/cognitoidentity/models.py @@ -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") diff --git a/moto/cognitoidentity/responses.py b/moto/cognitoidentity/responses.py index 34499ed02..ba1d157bc 100644 --- a/moto/cognitoidentity/responses.py +++ b/moto/cognitoidentity/responses.py @@ -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() diff --git a/tests/test_cognitoidentity/test_cognitoidentity.py b/tests/test_cognitoidentity/test_cognitoidentity.py index 197cc4647..742c27a81 100644 --- a/tests/test_cognitoidentity/test_cognitoidentity.py +++ b/tests/test_cognitoidentity/test_cognitoidentity.py @@ -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"]