@@ -62,6 +62,7 @@ void main() {
6262 username: username,
6363 password: password,
6464 );
65+
6566 check (
6667 resignInRes.nextStep.signInStep,
6768 ).equals (AuthSignInStep .confirmSignInWithOtpCode);
@@ -99,9 +100,18 @@ void main() {
99100 username: username,
100101 password: password,
101102 );
103+
102104 check (
103105 signInRes.nextStep.signInStep,
104- because: 'MFA is required so Cognito automatically enables SMS MFA' ,
106+ because: 'MFA is required so Cognito will ask for MFA type' ,
107+ ).equals (AuthSignInStep .continueSignInWithMfaSelection);
108+
109+ final selectMfaRes = await Amplify .Auth .confirmSignIn (
110+ confirmationValue: 'SMS' ,
111+ );
112+
113+ check (
114+ selectMfaRes.nextStep.signInStep,
105115 ).equals (AuthSignInStep .confirmSignInWithSmsMfaCode);
106116
107117 final confirmRes = await Amplify .Auth .confirmSignIn (
@@ -215,9 +225,18 @@ void main() {
215225 username: username,
216226 password: password,
217227 );
228+
218229 check (
219230 signInRes.nextStep.signInStep,
220- because: 'MFA is required so Cognito automatically enables SMS MFA' ,
231+ because: 'MFA is required so Cognito prompts MFA type selection' ,
232+ ).equals (AuthSignInStep .continueSignInWithMfaSelection);
233+
234+ final selectMfaRes = await Amplify .Auth .confirmSignIn (
235+ confirmationValue: 'SMS' ,
236+ );
237+
238+ check (
239+ selectMfaRes.nextStep.signInStep,
221240 ).equals (AuthSignInStep .confirmSignInWithSmsMfaCode);
222241
223242 final confirmRes = await Amplify .Auth .confirmSignIn (
@@ -227,44 +246,15 @@ void main() {
227246
228247 check (
229248 await cognitoPlugin.fetchMfaPreference (),
230- because: 'MFA is required so Cognito automatically enables SMS MFA' ,
249+ because:
250+ 'SMS MFA has been selected so Cognito fetches SMS as preferred' ,
231251 ).equals (
232252 const UserMfaPreference (
233253 enabled: {MfaType .sms},
234254 preferred: MfaType .sms,
235255 ),
236256 );
237257
238- // Verify we can set SMS as preferred and forego selection.
239-
240- {
241- await signOutUser (assertComplete: true );
242-
243- final mfaCode = await getOtpCode (UserAttribute .phone (phoneNumber));
244- final signInRes = await Amplify .Auth .signIn (
245- username: username,
246- password: password,
247- );
248- check (
249- signInRes.nextStep.signInStep,
250- because: 'Preference is SMS MFA now' ,
251- ).equals (AuthSignInStep .confirmSignInWithSmsMfaCode);
252- check (signInRes.nextStep.codeDeliveryDetails).isNotNull ()
253- ..has (
254- (d) => d.deliveryMedium,
255- 'deliveryMedium' ,
256- ).equals (DeliveryMedium .sms)
257- ..has (
258- (d) => d.destination,
259- 'destination' ,
260- ).isNotNull ().startsWith ('+' );
261-
262- final confirmRes = await Amplify .Auth .confirmSignIn (
263- confirmationValue: await mfaCode.code,
264- );
265- check (confirmRes.nextStep.signInStep).equals (AuthSignInStep .done);
266- }
267-
268258 // Verify we can switch to EMAIL as preferred.
269259
270260 await cognitoPlugin.updateMfaPreference (email: MfaPreference .preferred);
0 commit comments