Skip to content

chore(test): Authenticator EMAIL SNS MFA test fix #6148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c45b49c
chore(worker_bee): pinned analyzer version
tyllark May 15, 2025
5a07eec
updated email+sms mfa test to reflect updated cognito flow which now …
ekjotmultani May 19, 2025
d1b0edf
formatting
ekjotmultani May 19, 2025
748534c
test comment
ekjotmultani May 20, 2025
f29b92d
test
ekjotmultani May 20, 2025
845a546
change
ekjotmultani May 20, 2025
d6d978f
asdf
ekjotmultani May 20, 2025
18ed80d
added test print statement
ekjotmultani May 20, 2025
e79cf4c
changed to single quotes
ekjotmultani May 20, 2025
24affea
Merge branch 'chore/pin-analyzer' of https://github.com/aws-amplify/a…
ekjotmultani May 20, 2025
6060276
updated TabBarTheme to TabBarThemeData to enable test
ekjotmultani May 20, 2025
708b439
formatting
ekjotmultani May 20, 2025
720857d
fixed flutter breaking change https://docs.flutter.dev/release/breaki…
ekjotmultani May 20, 2025
122edf4
removed localizations to proceed with fixing authenticator mfa test
ekjotmultani May 21, 2025
794d38b
followed migration guide for localizations from flutter gen
ekjotmultani May 21, 2025
452af1a
removed unused imports
ekjotmultani May 21, 2025
5640857
further unused import cleanup
ekjotmultani May 21, 2025
a8baa4f
updated yaml
ekjotmultani May 21, 2025
1048893
Merge branch 'test/authenticator/mfa' changes to fix breaking changes…
ekjotmultani May 21, 2025
030a97f
now isolating cases causing slowdown
ekjotmultani May 21, 2025
18f7c94
changed otp parameter to be email
ekjotmultani May 21, 2025
afdb437
formatting
ekjotmultani May 21, 2025
b96138e
added check for mfa selection to sign out retry portion of sms test
ekjotmultani May 22, 2025
3f6536d
updated expect block
ekjotmultani May 22, 2025
9240f35
changed code in second test to sms code
ekjotmultani May 22, 2025
2f22c82
removed sms mfa check
ekjotmultani May 22, 2025
90e84de
second test case is irrelevant with the new flow, it will test the ex…
ekjotmultani May 22, 2025
c88ed15
regenerated worker files for proper formatting
ekjotmultani May 22, 2025
896a624
chore(): updated formatting
tyllark May 23, 2025
e3046c4
formatted files via command line
ekjotmultani May 23, 2025
106ead0
added version checking to formatter
ekjotmultani May 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/dart_vm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ jobs:
timeout-minutes: 20
run: aft bootstrap --fail-fast --include=${{ inputs.package-name }} --verbose

- name: Check Formatting Version
if: "always() && steps.bootstrap.conclusion == 'success' && matrix.sdk == 'stable'"
run: dart format --set-exit-if-changed --version .
working-directory: ${{ inputs.working-directory }}

- name: Check Formatting
if: "always() && steps.bootstrap.conclusion == 'success' && matrix.sdk == 'stable'"
run: dart format --set-exit-if-changed .
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_auth_integration_test/amplify_auth_integration_test.dart';
import 'package:amplify_authenticator_test/amplify_authenticator_test.dart';
import 'package:amplify_flutter/amplify_flutter.dart';
Expand Down Expand Up @@ -43,6 +42,7 @@ void main() {
tester.bloc.stream,
emitsInOrder([
UnauthenticatedState.signIn,
isA<ContinueSignInWithMfaSelection>(),
UnauthenticatedState.confirmSignInMfa,
isA<AuthenticatedState>(),
UnauthenticatedState.signIn,
Expand All @@ -58,7 +58,6 @@ void main() {
final smsResult = await getOtpCode(
UserAttribute.phone(phoneNumber.toE164()),
);

// When I type my "username"
await signInPage.enterUsername(username);

Expand All @@ -68,6 +67,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 "SMS"
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();

Expand Down Expand Up @@ -115,107 +123,6 @@ void main() {

await tester.bloc.close();
});

// Scenario: Sign in using a SMS code when both SMS and TOTP are enabled
testWidgets('can select SMS MFA', (tester) async {
final username = env.generateUsername();
final password = generatePassword();
final phoneNumber = generateUSPhoneNumber();

await adminCreateUser(
username,
password,
autoConfirm: true,
verifyAttributes: false,
attributes: {
AuthUserAttributeKey.phoneNumber: phoneNumber.toE164(),
AuthUserAttributeKey.email: username,
},
);

await loadAuthenticator(tester: tester);

expect(
tester.bloc.stream,
emitsInOrder([
UnauthenticatedState.signIn,
UnauthenticatedState.confirmSignInMfa,
isA<AuthenticatedState>(),
UnauthenticatedState.signIn,
UnauthenticatedState.confirmSignInMfa,
isA<AuthenticatedState>(),
emitsDone,
]),
);

final signInPage = SignInPage(tester: tester);
final confirmSignInPage = ConfirmSignInPage(tester: tester);

final smsResult_1 = await getOtpCode(
UserAttribute.phone(phoneNumber.toE164()),
);

// When I type my "username"
await signInPage.enterUsername(username);

// And I type my password
await signInPage.enterPassword(password);

// And I click the "Sign in" button
await signInPage.submitSignIn();

// Then I will be redirected to the confirm sms mfa page
await confirmSignInPage.expectConfirmSignInMFAIsPresent();

// When I type a valid confirmation code
await confirmSignInPage.enterVerificationCode(await smsResult_1.code);

// And I click the "Confirm" button
await confirmSignInPage.submitConfirmSignIn();

// Then I see the authenticated app
await signInPage.expectAuthenticated();

// When I enable EMAIL for MFA instead of the default set up by cognito (SMS)
await setUpEmailMfa();

final plugin = Amplify.Auth.getPlugin(AmplifyAuthCognito.pluginKey);
await plugin.updateMfaPreference(sms: MfaPreference.preferred);

// And I sign out using Auth.signOut()
await Amplify.Auth.signOut();
await tester.pumpAndSettle();

final smsResult_2 = await getOtpCode(
UserAttribute.phone(phoneNumber.toE164()),
);

// Then I see the sign in page
signInPage.expectEmail();

// When I type my "username"
await signInPage.enterUsername(username);

// And I type my password
await signInPage.enterPassword(password);

// And I click the "Sign in" button
await signInPage.submitSignIn();

// Then I will be redirected to the confirm sms mfa page
await confirmSignInPage.expectConfirmSignInMFAIsPresent();

// When I type a valid confirmation code
await confirmSignInPage.enterVerificationCode(await smsResult_2.code);

// And I click the "Confirm" button
await confirmSignInPage.submitConfirmSignIn();

// Then I see the authenticated app
await signInPage.expectAuthenticated();

await tester.bloc.close();
});
});
});
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
arb-dir: lib/l10n
template-arb-file: amplify_en.arb
output-localization-file: app_localizations.dart
synthetic-package: false

# To make use of Authenticator enums
header: import 'package:amplify_authenticator/amplify_authenticator.dart';
#header: import 'package:amplify_authenticator/amplify_authenticator.dart';

nullable-getter: false
Loading
Loading