@@ -62,6 +62,7 @@ void main() {
62
62
username: username,
63
63
password: password,
64
64
);
65
+
65
66
check (
66
67
resignInRes.nextStep.signInStep,
67
68
).equals (AuthSignInStep .confirmSignInWithOtpCode);
@@ -99,9 +100,18 @@ void main() {
99
100
username: username,
100
101
password: password,
101
102
);
103
+
102
104
check (
103
105
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,
105
115
).equals (AuthSignInStep .confirmSignInWithSmsMfaCode);
106
116
107
117
final confirmRes = await Amplify .Auth .confirmSignIn (
@@ -215,9 +225,18 @@ void main() {
215
225
username: username,
216
226
password: password,
217
227
);
228
+
218
229
check (
219
230
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,
221
240
).equals (AuthSignInStep .confirmSignInWithSmsMfaCode);
222
241
223
242
final confirmRes = await Amplify .Auth .confirmSignIn (
@@ -227,44 +246,15 @@ void main() {
227
246
228
247
check (
229
248
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' ,
231
251
).equals (
232
252
const UserMfaPreference (
233
253
enabled: {MfaType .sms},
234
254
preferred: MfaType .sms,
235
255
),
236
256
);
237
257
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
-
268
258
// Verify we can switch to EMAIL as preferred.
269
259
270
260
await cognitoPlugin.updateMfaPreference (email: MfaPreference .preferred);
0 commit comments