From f332d126512fd9e28cbe07f4b3fdb36ab9cff4cb Mon Sep 17 00:00:00 2001 From: Harshdeep Singh <6162866+harsh62@users.noreply.github.com> Date: Tue, 15 Oct 2024 11:33:32 -0400 Subject: [PATCH] update emailMFACode step to confirmSignInWithOTP --- Amplify/Categories/Auth/Models/AuthSignInStep.swift | 10 +++++----- .../Actions/SignIn/InitializeResolveChallenge.swift | 2 +- .../ClientBehaviorTests/SignIn/EmailMFATests.swift | 10 +++++----- .../MFATests/EmailMFATests/EmailMFAOnlyTests.swift | 10 +++++----- .../EmailMFAWithAllMFATypesRequiredTests.swift | 8 ++++---- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Amplify/Categories/Auth/Models/AuthSignInStep.swift b/Amplify/Categories/Auth/Models/AuthSignInStep.swift index ba02152d61..26837b627b 100644 --- a/Amplify/Categories/Auth/Models/AuthSignInStep.swift +++ b/Amplify/Categories/Auth/Models/AuthSignInStep.swift @@ -43,15 +43,15 @@ public enum AuthSignInStep { /// case continueSignInWithEmailMFASetup - /// Auth step is EMAIL multi factor authentication. - /// - /// Confirmation code for the MFA will be send to the provided EMAIL. - case confirmSignInWithEmailMFACode(AuthCodeDeliveryDetails) - /// Auth step is for continuing sign in by selecting multi factor authentication type to setup /// case continueSignInWithMFASetupSelection(AllowedMFATypes) + /// Auth step is for confirming sign in with OTP + /// + /// OTP for the factor will be sent to the delivery medium. + case confirmSignInWithOTP(AuthCodeDeliveryDetails) + /// Auth step required the user to change their password. /// case resetPassword(AdditionalInfo?) diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/InitializeResolveChallenge.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/InitializeResolveChallenge.swift index 3d37525eb8..f631e133d3 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/InitializeResolveChallenge.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/InitializeResolveChallenge.swift @@ -51,7 +51,7 @@ struct InitializeResolveChallenge: Action { case .selectMFAType: return .continueSignInWithMFASelection(challenge.getAllowedMFATypesForSelection) case .emailMFA: - return .confirmSignInWithEmailMFACode(challenge.codeDeliveryDetails) + return .confirmSignInWithOTP(challenge.codeDeliveryDetails) case .setUpMFA: var allowedMFATypesForSetup = challenge.getAllowedMFATypesForSetup // remove SMS, as it is not supported and should not be sent back to the customer, since it could be misleading diff --git a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/EmailMFATests.swift b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/EmailMFATests.swift index 7be4e8960e..92e34f6898 100644 --- a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/EmailMFATests.swift +++ b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/EmailMFATests.swift @@ -97,14 +97,14 @@ class EmailMFATests: BasePluginTest { } } - /// Test a signIn with valid inputs getting confirmSignInWithEmailMFACode challenge + /// Test a signIn with valid inputs getting confirmSignInWithOTP challenge /// /// - Given: Given an auth plugin with mocked service. /// /// - When: /// - I invoke signIn with valid values /// - Then: - /// - I should get a .confirmSignInWithEmailMFACode response + /// - I should get a .confirmSignInWithOTP response /// func testSuccessfulEmailMFACodeStep() async { var signInStepIterator = 0 @@ -134,8 +134,8 @@ class EmailMFATests: BasePluginTest { username: "username", password: "password", options: AuthSignInRequest.Options()) - guard case .confirmSignInWithEmailMFACode(let codeDetails) = result.nextStep else { - XCTFail("Result should be .confirmSignInWithEmailMFACode for next step, instead got: \(result.nextStep)") + guard case .confirmSignInWithOTP(let codeDetails) = result.nextStep else { + XCTFail("Result should be .confirmSignInWithOTP for next step, instead got: \(result.nextStep)") return } if case .email(let destination) = codeDetails.destination { @@ -232,7 +232,7 @@ class EmailMFATests: BasePluginTest { signInStepIterator = 1 confirmSignInResult = try await plugin.confirmSignIn( challengeResponse: "test@test.com") - guard case .confirmSignInWithEmailMFACode(let deliveryDetails) = confirmSignInResult.nextStep else { + guard case .confirmSignInWithOTP(let deliveryDetails) = confirmSignInResult.nextStep else { XCTFail("Result should be .continueSignInWithEmailMFASetup but got: \(confirmSignInResult.nextStep)") return } diff --git a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/MFATests/EmailMFATests/EmailMFAOnlyTests.swift b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/MFATests/EmailMFATests/EmailMFAOnlyTests.swift index bac8447467..6f1be2aa0e 100644 --- a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/MFATests/EmailMFATests/EmailMFAOnlyTests.swift +++ b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/MFATests/EmailMFATests/EmailMFAOnlyTests.swift @@ -89,8 +89,8 @@ class EmailMFARequiredTests: AWSAuthBaseTest { challengeResponse: username + "@integTest.com") // Step 6: Ensure that the next step is to confirm the Email MFA code - guard case .confirmSignInWithEmailMFACode(let deliveryDetails) = confirmSignInResult.nextStep else { - XCTFail("Expected .confirmSignInWithEmailMFACode step, got \(confirmSignInResult.nextStep)") + guard case .confirmSignInWithOTP(let deliveryDetails) = confirmSignInResult.nextStep else { + XCTFail("Expected .confirmSignInWithOTP step, got \(confirmSignInResult.nextStep)") return } if case .email(let destination) = deliveryDetails.destination { @@ -137,7 +137,7 @@ class EmailMFARequiredTests: AWSAuthBaseTest { /// they should successfully complete the MFA process and sign in. /// /// - MFA Setup Flow: - /// - Step 1: User signs in and receives the `confirmSignInWithEmailMFACode` challenge. + /// - Step 1: User signs in and receives the `confirmSignInWithOTP` challenge. /// - Step 2: User enters an incorrect MFA code and receives a `codeMismatch` error. /// - Step 3: User enters the correct MFA code. /// - Step 4: Sign-in completes, and the email is associated with the user account. @@ -165,8 +165,8 @@ class EmailMFARequiredTests: AWSAuthBaseTest { options: options) // Step 6: Ensure that the next step is to confirm the Email MFA code - guard case .confirmSignInWithEmailMFACode(let deliveryDetails) = result.nextStep else { - XCTFail("Expected .confirmSignInWithEmailMFACode step, got \(result.nextStep)") + guard case .confirmSignInWithOTP(let deliveryDetails) = result.nextStep else { + XCTFail("Expected .confirmSignInWithOTP step, got \(result.nextStep)") return } if case .email(let destination) = deliveryDetails.destination { diff --git a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/MFATests/EmailMFATests/EmailMFAWithAllMFATypesRequiredTests.swift b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/MFATests/EmailMFATests/EmailMFAWithAllMFATypesRequiredTests.swift index 8b6dc32616..88dd39ec57 100644 --- a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/MFATests/EmailMFATests/EmailMFAWithAllMFATypesRequiredTests.swift +++ b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/MFATests/EmailMFATests/EmailMFAWithAllMFATypesRequiredTests.swift @@ -112,8 +112,8 @@ class EmailMFAWithAllMFATypesRequiredTests: AWSAuthBaseTest { options: AuthSignInRequest.Options()) // Step 4: Verify that the next step is to confirm the Email MFA code - guard case .confirmSignInWithEmailMFACode(let codeDetails) = result.nextStep else { - XCTFail("Expected .confirmSignInWithEmailMFACode step, got \(result.nextStep)") + guard case .confirmSignInWithOTP(let codeDetails) = result.nextStep else { + XCTFail("Expected .confirmSignInWithOTP step, got \(result.nextStep)") return } if case .email(let destination) = codeDetails.destination { @@ -193,8 +193,8 @@ class EmailMFAWithAllMFATypesRequiredTests: AWSAuthBaseTest { challengeResponse: username + "@integTest.com") // Step 8: Verify that the next step is to confirm the Email MFA code - guard case .confirmSignInWithEmailMFACode(let deliveryDetails) = confirmSignInResult.nextStep else { - XCTFail("Expected .confirmSignInWithEmailMFACode step") + guard case .confirmSignInWithOTP(let deliveryDetails) = confirmSignInResult.nextStep else { + XCTFail("Expected .confirmSignInWithOTP step") return } if case .email(let destination) = deliveryDetails.destination {