From b3fa9bbb08f81248d34f587f420bc91ec105cbd6 Mon Sep 17 00:00:00 2001 From: cm-iwata <38879253+cm-iwata@users.noreply.github.com> Date: Sat, 30 Dec 2023 23:20:36 +0900 Subject: [PATCH] CognitoIDP: fix no scopes in create_resource_server (#7163) (#7167) --- moto/cognitoidp/models.py | 2 +- tests/test_cognitoidp/test_cognitoidp.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/moto/cognitoidp/models.py b/moto/cognitoidp/models.py index 577e194de..f0cc9082f 100644 --- a/moto/cognitoidp/models.py +++ b/moto/cognitoidp/models.py @@ -909,7 +909,7 @@ class CognitoResourceServer(BaseModel): "Name": self.name, } - if len(self.scopes) != 0: + if self.scopes: res.update({"Scopes": self.scopes}) return res diff --git a/tests/test_cognitoidp/test_cognitoidp.py b/tests/test_cognitoidp/test_cognitoidp.py index 9b5b1db1f..ed2851096 100644 --- a/tests/test_cognitoidp/test_cognitoidp.py +++ b/tests/test_cognitoidp/test_cognitoidp.py @@ -3578,6 +3578,26 @@ def test_create_resource_server(): assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400 +@mock_cognitoidp +def test_create_resource_server_with_no_scopes(): + client = boto3.client("cognito-idp", "us-west-2") + name = str(uuid.uuid4()) + res = client.create_user_pool(PoolName=name) + + user_pool_id = res["UserPool"]["Id"] + identifier = "http://localhost.localdomain" + name = "local server" + + res = client.create_resource_server( + UserPoolId=user_pool_id, Identifier=identifier, Name=name + ) + + assert res["ResourceServer"]["UserPoolId"] == user_pool_id + assert res["ResourceServer"]["Identifier"] == identifier + assert res["ResourceServer"]["Name"] == name + assert "Scopes" not in res["ResourceServer"] + + @mock_cognitoidp def test_describe_resource_server():