From a4f58f0774d70aaa07eda0026a2241d790db7368 Mon Sep 17 00:00:00 2001 From: mianowski Date: Thu, 10 Mar 2022 15:38:43 +0100 Subject: [PATCH] CognitoIdp fixes (#4518) --- moto/cognitoidp/models.py | 2 +- tests/test_cognitoidp/test_cognitoidp.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/moto/cognitoidp/models.py b/moto/cognitoidp/models.py index fb77e66881e..15aa01455bf 100644 --- a/moto/cognitoidp/models.py +++ b/moto/cognitoidp/models.py @@ -1525,7 +1525,7 @@ def initiate_auth(self, client_id, auth_flow, auth_parameters): "ChallengeParameters": { "SALT": uuid.uuid4().hex, "SRP_B": uuid.uuid4().hex, - "USERNAME": user.id, + "USERNAME": user.username, "USER_ID_FOR_SRP": user.id, "SECRET_BLOCK": session, }, diff --git a/tests/test_cognitoidp/test_cognitoidp.py b/tests/test_cognitoidp/test_cognitoidp.py index 1219be4b6c6..671c179bdbc 100644 --- a/tests/test_cognitoidp/test_cognitoidp.py +++ b/tests/test_cognitoidp/test_cognitoidp.py @@ -2561,6 +2561,7 @@ def user_authentication_flow(conn): result["AuthenticationResult"]["IdToken"].should_not.be.none result["AuthenticationResult"]["AccessToken"].should_not.be.none + result["AuthenticationResult"]["TokenType"].should.equal("Bearer") # authenticate user once again this time with mfa token result = conn.initiate_auth( @@ -3317,6 +3318,7 @@ def test_initiate_auth_USER_SRP_AUTH(): ) result["ChallengeName"].should.equal("PASSWORD_VERIFIER") + result["ChallengeParameters"]["USERNAME"].should.equal(username) @mock_cognitoidp @@ -3385,6 +3387,7 @@ def test_initiate_auth_USER_PASSWORD_AUTH(): result["AuthenticationResult"]["AccessToken"].should_not.be.none result["AuthenticationResult"]["IdToken"].should_not.be.none result["AuthenticationResult"]["RefreshToken"].should_not.be.none + result["AuthenticationResult"]["TokenType"].should.equal("Bearer") @mock_cognitoidp