From cd4fe2736c864a72e89967ce4504688acd3ffe98 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Mon, 5 May 2025 14:35:19 -0700 Subject: [PATCH 01/30] added emailmfa attribute to first user sign up in test --- .../example/integration_test/mfa_sms_email_required_test.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index f2fc213ee8..6cd35f7921 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -89,6 +89,7 @@ void main() { password, autoConfirm: true, verifyAttributes: false, + enableMfa: true, attributes: { AuthUserAttributeKey.phoneNumber: phoneNumber, AuthUserAttributeKey.email: username, From 2f207c235e8b8cc694c41106be2a7980dea4ab55 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Mon, 5 May 2025 16:36:28 -0700 Subject: [PATCH 02/30] updated test --- .../mfa_sms_email_required_test.dart | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index 6cd35f7921..011eb7382d 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -89,7 +89,6 @@ void main() { password, autoConfirm: true, verifyAttributes: false, - enableMfa: true, attributes: { AuthUserAttributeKey.phoneNumber: phoneNumber, AuthUserAttributeKey.email: username, @@ -100,10 +99,17 @@ void main() { username: username, password: password, ); + // as of May 2025, cognito has stopped defaulting to sms mfa and now asks for mfa type selection in the normal flow check( signInRes.nextStep.signInStep, - because: 'MFA is required so Cognito automatically enables SMS MFA', - ).equals(AuthSignInStep.confirmSignInWithSmsMfaCode); + because: 'MFA is required so Cognito automatically enables SMS MFA', // change + ).equals(AuthSignInStep.continueSignInWithMfaSelection); + + final selectMfaRes = await Amplify.Auth.confirmSignIn( + confirmationValue: 'SMS_MFA' + ); + + check(selectMfaRes.nextStep.signInStep).equals(AuthSignInStep.confirmSignInWithSmsMfaCode); final confirmRes = await Amplify.Auth.confirmSignIn( confirmationValue: await mfaCode.code, From ffd86911325d70ad4c806aa591da4e5ae8510ec2 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Mon, 5 May 2025 16:40:53 -0700 Subject: [PATCH 03/30] formatting --- .../integration_test/mfa_sms_email_required_test.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index 011eb7382d..4ed3e5f580 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -102,14 +102,17 @@ void main() { // as of May 2025, cognito has stopped defaulting to sms mfa and now asks for mfa type selection in the normal flow check( signInRes.nextStep.signInStep, - because: 'MFA is required so Cognito automatically enables SMS MFA', // change + because: + 'MFA is required so Cognito automatically enables SMS MFA', // change ).equals(AuthSignInStep.continueSignInWithMfaSelection); final selectMfaRes = await Amplify.Auth.confirmSignIn( - confirmationValue: 'SMS_MFA' + confirmationValue: 'SMS_MFA', ); - - check(selectMfaRes.nextStep.signInStep).equals(AuthSignInStep.confirmSignInWithSmsMfaCode); + + check( + selectMfaRes.nextStep.signInStep, + ).equals(AuthSignInStep.confirmSignInWithSmsMfaCode); final confirmRes = await Amplify.Auth.confirmSignIn( confirmationValue: await mfaCode.code, From f454bde1099b6a5e7c2ea285e007bf8f79b64da9 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Tue, 6 May 2025 16:04:52 -0700 Subject: [PATCH 04/30] changed confirmation value of sign in portion --- .../example/integration_test/mfa_sms_email_required_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index 4ed3e5f580..c530b599ee 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -107,7 +107,7 @@ void main() { ).equals(AuthSignInStep.continueSignInWithMfaSelection); final selectMfaRes = await Amplify.Auth.confirmSignIn( - confirmationValue: 'SMS_MFA', + confirmationValue: 'SMS', ); check( From 61899ba4fb48fd3b8f6738af87d098fe1b154de4 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Wed, 7 May 2025 12:16:22 -0700 Subject: [PATCH 05/30] updated second test --- .../mfa_sms_email_required_test.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index c530b599ee..0f258c2b53 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -225,9 +225,19 @@ void main() { username: username, password: password, ); + check( signInRes.nextStep.signInStep, - because: 'MFA is required so Cognito automatically enables SMS MFA', + because: + 'MFA is required so Cognito automatically enables SMS MFA', // change + ).equals(AuthSignInStep.continueSignInWithMfaSelection); + + final selectMfaRes = await Amplify.Auth.confirmSignIn( + confirmationValue: 'SMS', + ); + + check( + selectMfaRes.nextStep.signInStep, ).equals(AuthSignInStep.confirmSignInWithSmsMfaCode); final confirmRes = await Amplify.Auth.confirmSignIn( From d74e36ae84366725ab1cb2d9351ad08bf138e3dc Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Wed, 7 May 2025 13:29:10 -0700 Subject: [PATCH 06/30] updated portion of test which verifies that we can set sms mfa to be the preferred option --- .../integration_test/mfa_sms_email_required_test.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index 0f258c2b53..26528c92e9 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -260,6 +260,13 @@ void main() { { await signOutUser(assertComplete: true); + await cognitoPlugin.updateMfaPreference(sms: MfaPreference.preferred); + check(await cognitoPlugin.fetchMfaPreference()).equals( + const UserMfaPreference( + enabled: {MfaType.sms, MfaType.email}, + preferred: MfaType.sms, + ), + ); final mfaCode = await getOtpCode(UserAttribute.phone(phoneNumber)); final signInRes = await Amplify.Auth.signIn( username: username, From ca60c162f214a959f9b1462c6ed7fadef28b10d4 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Wed, 7 May 2025 14:24:52 -0700 Subject: [PATCH 07/30] updated test order --- .../integration_test/mfa_sms_email_required_test.dart | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index 26528c92e9..18bfa08b06 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -259,14 +259,21 @@ void main() { { await signOutUser(assertComplete: true); - - await cognitoPlugin.updateMfaPreference(sms: MfaPreference.preferred); check(await cognitoPlugin.fetchMfaPreference()).equals( const UserMfaPreference( enabled: {MfaType.sms, MfaType.email}, preferred: MfaType.sms, ), ); + await cognitoPlugin.updateMfaPreference( + email: MfaPreference.preferred, + ); + check(await cognitoPlugin.fetchMfaPreference()).equals( + const UserMfaPreference( + enabled: {MfaType.sms, MfaType.email}, + preferred: MfaType.email, + ), + ); final mfaCode = await getOtpCode(UserAttribute.phone(phoneNumber)); final signInRes = await Amplify.Auth.signIn( username: username, From 1343287f229be7dfa3f04a26ed1120191ec75d9d Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Wed, 7 May 2025 15:15:19 -0700 Subject: [PATCH 08/30] removed sign out when user is not signed in --- .../example/integration_test/mfa_sms_email_required_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index 18bfa08b06..dcdbb0d12d 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -258,7 +258,7 @@ void main() { // Verify we can set SMS as preferred and forego selection. { - await signOutUser(assertComplete: true); + //await signOutUser(assertComplete: true); check(await cognitoPlugin.fetchMfaPreference()).equals( const UserMfaPreference( enabled: {MfaType.sms, MfaType.email}, From 7ebded31d905d0b14d709a464ea990ee502fc0ae Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Thu, 8 May 2025 12:12:21 -0700 Subject: [PATCH 09/30] changed mfa preference flow for verifying if we can set sms as preferred and forego selection of mfa type upon sign in --- .../integration_test/mfa_sms_email_required_test.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index dcdbb0d12d..e204424037 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -254,14 +254,15 @@ void main() { preferred: MfaType.sms, ), ); + await signOutUser(assertComplete: true); // Verify we can set SMS as preferred and forego selection. { - //await signOutUser(assertComplete: true); + check(await cognitoPlugin.fetchMfaPreference()).equals( const UserMfaPreference( - enabled: {MfaType.sms, MfaType.email}, + enabled: {MfaType.sms}, preferred: MfaType.sms, ), ); From 3facd61c0936d2cfbc7532db22d933d9fa0e6c0e Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Thu, 8 May 2025 12:19:26 -0700 Subject: [PATCH 10/30] formatting --- .../example/integration_test/mfa_sms_email_required_test.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index e204424037..f76eda51d0 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -259,7 +259,6 @@ void main() { // Verify we can set SMS as preferred and forego selection. { - check(await cognitoPlugin.fetchMfaPreference()).equals( const UserMfaPreference( enabled: {MfaType.sms}, From 17963413f7710813775fd9c0d4b2c6c9d33f1c50 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Thu, 8 May 2025 14:02:44 -0700 Subject: [PATCH 11/30] formatting --- .../example/integration_test/mfa_sms_email_required_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index f76eda51d0..a0ef6b4acc 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -254,7 +254,7 @@ void main() { preferred: MfaType.sms, ), ); - await signOutUser(assertComplete: true); + //await signOutUser(assertComplete: true); // Verify we can set SMS as preferred and forego selection. From a8bc0c144777dea5eb80a925eee9a2bed8607b3d Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Thu, 8 May 2025 14:57:52 -0700 Subject: [PATCH 12/30] sign out user before signing in --- .../example/integration_test/mfa_sms_email_required_test.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index a0ef6b4acc..e2dee840b1 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -275,6 +275,7 @@ void main() { ), ); final mfaCode = await getOtpCode(UserAttribute.phone(phoneNumber)); + await signOutUser(); final signInRes = await Amplify.Auth.signIn( username: username, password: password, From d404149b66322edef665483ae7f9ceadce925adc Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Fri, 9 May 2025 11:36:23 -0700 Subject: [PATCH 13/30] updating test --- .../integration_test/mfa_sms_email_required_test.dart | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index e2dee840b1..8bdb6a25ab 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -280,11 +280,16 @@ void main() { username: username, password: password, ); + + // as of May 2025, cognito has stopped defaulting to sms mfa and now asks for mfa type selection in the normal flow + final selectMfaRes = await Amplify.Auth.confirmSignIn( + confirmationValue: 'SMS', + ); check( - signInRes.nextStep.signInStep, - because: 'Preference is SMS MFA now', + selectMfaRes.nextStep.signInStep, ).equals(AuthSignInStep.confirmSignInWithSmsMfaCode); - check(signInRes.nextStep.codeDeliveryDetails).isNotNull() + + check(selectMfaRes.nextStep.codeDeliveryDetails).isNotNull() ..has( (d) => d.deliveryMedium, 'deliveryMedium', From f838a69ac60c0b8fe54d640faf4ef53a1f783e31 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Fri, 9 May 2025 11:58:20 -0700 Subject: [PATCH 14/30] formatting --- .../example/integration_test/mfa_sms_email_required_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index 8bdb6a25ab..78e1e2e5d6 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -281,7 +281,7 @@ void main() { password: password, ); - // as of May 2025, cognito has stopped defaulting to sms mfa and now asks for mfa type selection in the normal flow + // as of May 2025, cognito has stopped defaulting to sms mfa and now asks for mfa type selection in the normal flow final selectMfaRes = await Amplify.Auth.confirmSignIn( confirmationValue: 'SMS', ); From b25f0ab904224b2ad97d38fac94ac8e6bc73cc59 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Fri, 9 May 2025 12:03:02 -0700 Subject: [PATCH 15/30] removed unused variable --- .../example/integration_test/mfa_sms_email_required_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index 78e1e2e5d6..91cdd0233a 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -276,7 +276,7 @@ void main() { ); final mfaCode = await getOtpCode(UserAttribute.phone(phoneNumber)); await signOutUser(); - final signInRes = await Amplify.Auth.signIn( + await Amplify.Auth.signIn( username: username, password: password, ); From 22087052054d6733491d239ac3d5c84a96e40ac0 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Fri, 9 May 2025 12:07:28 -0700 Subject: [PATCH 16/30] formatting --- .../integration_test/mfa_sms_email_required_test.dart | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index 91cdd0233a..8c4345296b 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -276,10 +276,7 @@ void main() { ); final mfaCode = await getOtpCode(UserAttribute.phone(phoneNumber)); await signOutUser(); - await Amplify.Auth.signIn( - username: username, - password: password, - ); + await Amplify.Auth.signIn(username: username, password: password); // as of May 2025, cognito has stopped defaulting to sms mfa and now asks for mfa type selection in the normal flow final selectMfaRes = await Amplify.Auth.confirmSignIn( From 67c1e329031ca4b0984e4d7db33dc8ae046d2bf4 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Fri, 9 May 2025 14:32:27 -0700 Subject: [PATCH 17/30] updated test --- .../mfa_sms_email_required_test.dart | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index 8c4345296b..d7668001dc 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -259,24 +259,18 @@ void main() { // Verify we can set SMS as preferred and forego selection. { - check(await cognitoPlugin.fetchMfaPreference()).equals( - const UserMfaPreference( - enabled: {MfaType.sms}, - preferred: MfaType.sms, - ), - ); await cognitoPlugin.updateMfaPreference( - email: MfaPreference.preferred, + sms: MfaPreference.preferred, ); check(await cognitoPlugin.fetchMfaPreference()).equals( const UserMfaPreference( enabled: {MfaType.sms, MfaType.email}, - preferred: MfaType.email, + preferred: MfaType.sms, ), ); final mfaCode = await getOtpCode(UserAttribute.phone(phoneNumber)); await signOutUser(); - await Amplify.Auth.signIn(username: username, password: password); + await Amplify.Auth.signIn(username: username, password: password); // NOW: this is going to auth state that expects an otp code, but the test originally was working with this state as expecting an mfa code.... // as of May 2025, cognito has stopped defaulting to sms mfa and now asks for mfa type selection in the normal flow final selectMfaRes = await Amplify.Auth.confirmSignIn( From a6dd53e4ee12ee905d595fe3bffcf3788358985f Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Fri, 9 May 2025 14:45:54 -0700 Subject: [PATCH 18/30] formatting --- .../integration_test/mfa_sms_email_required_test.dart | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index d7668001dc..67017934d0 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -259,9 +259,7 @@ void main() { // Verify we can set SMS as preferred and forego selection. { - await cognitoPlugin.updateMfaPreference( - sms: MfaPreference.preferred, - ); + await cognitoPlugin.updateMfaPreference(sms: MfaPreference.preferred); check(await cognitoPlugin.fetchMfaPreference()).equals( const UserMfaPreference( enabled: {MfaType.sms, MfaType.email}, @@ -270,7 +268,10 @@ void main() { ); final mfaCode = await getOtpCode(UserAttribute.phone(phoneNumber)); await signOutUser(); - await Amplify.Auth.signIn(username: username, password: password); // NOW: this is going to auth state that expects an otp code, but the test originally was working with this state as expecting an mfa code.... + await Amplify.Auth.signIn( + username: username, + password: password, + ); // NOW: this is going to auth state that expects an otp code, but the test originally was working with this state as expecting an mfa code.... // as of May 2025, cognito has stopped defaulting to sms mfa and now asks for mfa type selection in the normal flow final selectMfaRes = await Amplify.Auth.confirmSignIn( From be8ccc9d30f3b47efa9b78024d3923a970855efa Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Fri, 9 May 2025 16:05:56 -0700 Subject: [PATCH 19/30] changed accepted mfa types for default to sms test --- .../example/integration_test/mfa_sms_email_required_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index 67017934d0..adb0c96c29 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -262,7 +262,7 @@ void main() { await cognitoPlugin.updateMfaPreference(sms: MfaPreference.preferred); check(await cognitoPlugin.fetchMfaPreference()).equals( const UserMfaPreference( - enabled: {MfaType.sms, MfaType.email}, + enabled: {MfaType.sms}, preferred: MfaType.sms, ), ); From 908943c85918b4a1eda9e5096d01ab5d762c7d0f Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Mon, 12 May 2025 13:15:26 -0700 Subject: [PATCH 20/30] updates --- .../integration_test/mfa_sms_email_required_test.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index adb0c96c29..3dd1aa1c04 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -274,9 +274,9 @@ void main() { ); // NOW: this is going to auth state that expects an otp code, but the test originally was working with this state as expecting an mfa code.... // as of May 2025, cognito has stopped defaulting to sms mfa and now asks for mfa type selection in the normal flow - final selectMfaRes = await Amplify.Auth.confirmSignIn( - confirmationValue: 'SMS', - ); + //final selectMfaRes = await Amplify.Auth.confirmSignIn( + // confirmationValue: 'SMS', + //); check( selectMfaRes.nextStep.signInStep, ).equals(AuthSignInStep.confirmSignInWithSmsMfaCode); From 1a97fd4ed2d27273264149ef8600f43268c1627e Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Mon, 12 May 2025 14:27:29 -0700 Subject: [PATCH 21/30] cleaned up comments --- .../integration_test/mfa_sms_email_required_test.dart | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index 3dd1aa1c04..89e6f06e9f 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -254,7 +254,6 @@ void main() { preferred: MfaType.sms, ), ); - //await signOutUser(assertComplete: true); // Verify we can set SMS as preferred and forego selection. @@ -268,15 +267,8 @@ void main() { ); final mfaCode = await getOtpCode(UserAttribute.phone(phoneNumber)); await signOutUser(); - await Amplify.Auth.signIn( - username: username, - password: password, - ); // NOW: this is going to auth state that expects an otp code, but the test originally was working with this state as expecting an mfa code.... + await Amplify.Auth.signIn(username: username, password: password); - // as of May 2025, cognito has stopped defaulting to sms mfa and now asks for mfa type selection in the normal flow - //final selectMfaRes = await Amplify.Auth.confirmSignIn( - // confirmationValue: 'SMS', - //); check( selectMfaRes.nextStep.signInStep, ).equals(AuthSignInStep.confirmSignInWithSmsMfaCode); From 5bff06cacaa7a449b5bae1d225ca78bf69b82d2b Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Mon, 12 May 2025 17:52:54 -0700 Subject: [PATCH 22/30] removed duplicate test and changed "because" clause of test --- .../mfa_sms_email_required_test.dart | 38 +------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index 89e6f06e9f..bb038e2bf5 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -99,11 +99,11 @@ void main() { username: username, password: password, ); - // as of May 2025, cognito has stopped defaulting to sms mfa and now asks for mfa type selection in the normal flow + check( signInRes.nextStep.signInStep, because: - 'MFA is required so Cognito automatically enables SMS MFA', // change + 'MFA is required so Cognito will ask for MFA type', ).equals(AuthSignInStep.continueSignInWithMfaSelection); final selectMfaRes = await Amplify.Auth.confirmSignIn( @@ -255,40 +255,6 @@ void main() { ), ); - // Verify we can set SMS as preferred and forego selection. - - { - await cognitoPlugin.updateMfaPreference(sms: MfaPreference.preferred); - check(await cognitoPlugin.fetchMfaPreference()).equals( - const UserMfaPreference( - enabled: {MfaType.sms}, - preferred: MfaType.sms, - ), - ); - final mfaCode = await getOtpCode(UserAttribute.phone(phoneNumber)); - await signOutUser(); - await Amplify.Auth.signIn(username: username, password: password); - - check( - selectMfaRes.nextStep.signInStep, - ).equals(AuthSignInStep.confirmSignInWithSmsMfaCode); - - check(selectMfaRes.nextStep.codeDeliveryDetails).isNotNull() - ..has( - (d) => d.deliveryMedium, - 'deliveryMedium', - ).equals(DeliveryMedium.sms) - ..has( - (d) => d.destination, - 'destination', - ).isNotNull().startsWith('+'); - - final confirmRes = await Amplify.Auth.confirmSignIn( - confirmationValue: await mfaCode.code, - ); - check(confirmRes.nextStep.signInStep).equals(AuthSignInStep.done); - } - // Verify we can switch to EMAIL as preferred. await cognitoPlugin.updateMfaPreference(email: MfaPreference.preferred); From 46e16615f11aa3861f115740dedc691eb051c239 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Tue, 13 May 2025 13:50:57 -0700 Subject: [PATCH 23/30] formatting --- .../integration_test/mfa_sms_email_required_test.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index bb038e2bf5..1b5e74de06 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -62,6 +62,7 @@ void main() { username: username, password: password, ); + check( resignInRes.nextStep.signInStep, ).equals(AuthSignInStep.confirmSignInWithOtpCode); @@ -99,11 +100,10 @@ void main() { username: username, password: password, ); - + check( signInRes.nextStep.signInStep, - because: - 'MFA is required so Cognito will ask for MFA type', + because: 'MFA is required so Cognito will ask for MFA type', ).equals(AuthSignInStep.continueSignInWithMfaSelection); final selectMfaRes = await Amplify.Auth.confirmSignIn( From beee3b27d919b28aa585d740785ff07215ea306b Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Tue, 13 May 2025 13:54:34 -0700 Subject: [PATCH 24/30] changed test text to properly reflect the flow of the test --- .../integration_test/mfa_sms_email_required_test.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart index 1b5e74de06..a787d2809d 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_email_required_test.dart @@ -228,8 +228,7 @@ void main() { check( signInRes.nextStep.signInStep, - because: - 'MFA is required so Cognito automatically enables SMS MFA', // change + because: 'MFA is required so Cognito prompts MFA type selection', ).equals(AuthSignInStep.continueSignInWithMfaSelection); final selectMfaRes = await Amplify.Auth.confirmSignIn( @@ -247,7 +246,8 @@ void main() { check( await cognitoPlugin.fetchMfaPreference(), - because: 'MFA is required so Cognito automatically enables SMS MFA', + because: + 'SMS MFA has been selected so Cognito fetches SMS as preferred', ).equals( const UserMfaPreference( enabled: {MfaType.sms}, From fcfc3e0507f84ddab67a867243f6ba30696d61fa Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Thu, 15 May 2025 15:32:25 -0700 Subject: [PATCH 25/30] updated authenticator test to match new flow --- .../sign_in_mfa_sms_email_test.dart | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart b/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart index 9ecc0cde14..129721c961 100644 --- a/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart +++ b/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart @@ -68,6 +68,15 @@ void main() { // And I click the "Sign in" button await signInPage.submitSignIn(); + // Then I will be redirected to chose MFA type + await confirmSignInPage.expectConfirmSignInMfaSelectionIsPresent(); + + // When I select "TOTP" + await confirmSignInPage.selectMfaMethod(mfaMethod: MfaType.sms); + + // And I click the "Confirm" button + await confirmSignInPage.submitConfirmSignInMfaSelection(); + // Then I will be redirected to the confirm sms mfa page await confirmSignInPage.expectConfirmSignInMFAIsPresent(); @@ -164,6 +173,15 @@ void main() { // And I click the "Sign in" button await signInPage.submitSignIn(); + // Then I will be redirected to chose MFA type + await confirmSignInPage.expectConfirmSignInMfaSelectionIsPresent(); + + // When I select "TOTP" + await confirmSignInPage.selectMfaMethod(mfaMethod: MfaType.sms); + + // And I click the "Confirm" button + await confirmSignInPage.submitConfirmSignInMfaSelection(); + // Then I will be redirected to the confirm sms mfa page await confirmSignInPage.expectConfirmSignInMFAIsPresent(); @@ -202,6 +220,15 @@ void main() { // And I click the "Sign in" button await signInPage.submitSignIn(); + // Then I will be redirected to chose MFA type + await confirmSignInPage.expectConfirmSignInMfaSelectionIsPresent(); + + // When I select "TOTP" + await confirmSignInPage.selectMfaMethod(mfaMethod: MfaType.sms); + + // And I click the "Confirm" button + await confirmSignInPage.submitConfirmSignInMfaSelection(); + // Then I will be redirected to the confirm sms mfa page await confirmSignInPage.expectConfirmSignInMFAIsPresent(); From 6a9d1a5b49caee77d3a6701e72a450182e36b2de Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Thu, 15 May 2025 16:16:04 -0700 Subject: [PATCH 26/30] updated expect function to include mfa selection --- .../example/integration_test/sign_in_mfa_sms_email_test.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart b/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart index 129721c961..f70069270f 100644 --- a/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart +++ b/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart @@ -46,7 +46,8 @@ void main() { UnauthenticatedState.confirmSignInMfa, isA(), UnauthenticatedState.signIn, - UnauthenticatedState.confirmSignInWithOtpCode, + isA(), + UnauthenticatedState.confirmSignInMfa, isA(), emitsDone, ]), @@ -148,9 +149,11 @@ void main() { tester.bloc.stream, emitsInOrder([ UnauthenticatedState.signIn, + isA(), UnauthenticatedState.confirmSignInMfa, isA(), UnauthenticatedState.signIn, + isA(), UnauthenticatedState.confirmSignInMfa, isA(), emitsDone, From 5c4369221a5b63d6606e54e69d0916e6c473524d Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Fri, 16 May 2025 11:05:04 -0700 Subject: [PATCH 27/30] updated expect block for "can select SMS MFA" --- .../example/integration_test/sign_in_mfa_sms_email_test.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart b/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart index f70069270f..0d83011014 100644 --- a/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart +++ b/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart @@ -153,7 +153,6 @@ void main() { UnauthenticatedState.confirmSignInMfa, isA(), UnauthenticatedState.signIn, - isA(), UnauthenticatedState.confirmSignInMfa, isA(), emitsDone, From 69b7f5523214ad640027ba858ffacc96a092b634 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Fri, 16 May 2025 11:49:55 -0700 Subject: [PATCH 28/30] updated expect further --- .../example/integration_test/sign_in_mfa_sms_email_test.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart b/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart index 0d83011014..738601b699 100644 --- a/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart +++ b/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart @@ -43,11 +43,10 @@ void main() { tester.bloc.stream, emitsInOrder([ UnauthenticatedState.signIn, + isA(), UnauthenticatedState.confirmSignInMfa, isA(), UnauthenticatedState.signIn, - isA(), - UnauthenticatedState.confirmSignInMfa, isA(), emitsDone, ]), From b36ec06087093ee51dad3b8ce075fc85fa4d8659 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Fri, 16 May 2025 11:50:04 -0700 Subject: [PATCH 29/30] futher updates --- .../example/integration_test/sign_in_mfa_sms_email_test.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart b/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart index 738601b699..d422f0bfcf 100644 --- a/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart +++ b/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart @@ -47,7 +47,6 @@ void main() { UnauthenticatedState.confirmSignInMfa, isA(), UnauthenticatedState.signIn, - isA(), emitsDone, ]), ); From 94d05d1ab244d4cdf57b6bf69f6969b86d862130 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Fri, 16 May 2025 11:59:06 -0700 Subject: [PATCH 30/30] added back otp code check --- .../example/integration_test/sign_in_mfa_sms_email_test.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart b/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart index d422f0bfcf..8a6cf84a52 100644 --- a/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart +++ b/packages/authenticator/amplify_authenticator/example/integration_test/sign_in_mfa_sms_email_test.dart @@ -47,6 +47,8 @@ void main() { UnauthenticatedState.confirmSignInMfa, isA(), UnauthenticatedState.signIn, + UnauthenticatedState.confirmSignInWithOtpCode, + isA(), emitsDone, ]), );