diff --git a/Amplify/Categories/Auth/Result/AuthSignUpResult.swift b/Amplify/Categories/Auth/Result/AuthSignUpResult.swift index 012856908a..88853771b6 100644 --- a/Amplify/Categories/Auth/Result/AuthSignUpResult.swift +++ b/Amplify/Categories/Auth/Result/AuthSignUpResult.swift @@ -23,13 +23,7 @@ public struct AuthSignUpResult { /// public let nextStep: AuthSignUpStep - public let userID: String? - - public init( - _ nextStep: AuthSignUpStep, - userID: String? = nil - ) { + public init(_ nextStep: AuthSignUpStep) { self.nextStep = nextStep - self.userID = userID } } diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Service/Helpers/SignUpOutputResponse+Helper.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Service/Helpers/SignUpOutputResponse+Helper.swift index c6c4742008..c9706e53a0 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Service/Helpers/SignUpOutputResponse+Helper.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Service/Helpers/SignUpOutputResponse+Helper.swift @@ -13,15 +13,14 @@ extension SignUpOutputResponse { var authResponse: AuthSignUpResult { if self.userConfirmed { - return .init(.done, userID: userSub) + return .init(.done) } return AuthSignUpResult( .confirmUser( codeDeliveryDetails?.toAuthCodeDeliveryDetails(), nil, userSub - ), - userID: userSub + ) ) } } diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthConfirmSignUpTask.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthConfirmSignUpTask.swift index db0148eea5..f33017336c 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthConfirmSignUpTask.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthConfirmSignUpTask.swift @@ -41,7 +41,7 @@ class AWSAuthConfirmSignUpTask: AuthConfirmSignUpTask, DefaultLogger { environment: userPoolEnvironment) _ = try await client.confirmSignUp(input: input) log.verbose("Received success") - return AuthSignUpResult(.done, userID: nil) + return AuthSignUpResult(.done) } catch let error as AuthError { throw error } catch let error as AuthErrorConvertible { diff --git a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignUp/AWSAuthConfirmSignUpTaskTests.swift b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignUp/AWSAuthConfirmSignUpTaskTests.swift index 9236e24c98..f4a91a521d 100644 --- a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignUp/AWSAuthConfirmSignUpTaskTests.swift +++ b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignUp/AWSAuthConfirmSignUpTaskTests.swift @@ -45,7 +45,7 @@ class AWSAuthConfirmSignUpTaskTests: XCTestCase { let task = AWSAuthConfirmSignUpTask(request, authEnvironment: authEnvironment) let confirmSignUpResult = try await task.value print("Confirm Sign Up Result: \(confirmSignUpResult)") - await fulfillment(of: [functionExpectation], timeout: 1) + wait(for: [functionExpectation], timeout: 1) } func testConfirmSignUpOperationFailure() async throws { diff --git a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignUp/AWSAuthSignUpAPITests.swift b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignUp/AWSAuthSignUpAPITests.swift index b0f514aae8..c43745984b 100644 --- a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignUp/AWSAuthSignUpAPITests.swift +++ b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignUp/AWSAuthSignUpAPITests.swift @@ -126,65 +126,6 @@ class AWSAuthSignUpAPITests: BasePluginTest { XCTAssertFalse(result.isSignUpComplete, "Signin result should be complete") } - /// Given: A response from Cognito SignUp when `userConfirmed == true` and a present `userSub` - /// When: Invoking `signUp(username:password:options:)` - /// Then: The caller should receive an `AuthSignUpResult` where `nextStep == .done` and - /// `userID` is the `userSub` returned by the service. - func test_signUp_done_withUserSub() async throws { - let sub = UUID().uuidString - mockIdentityProvider = MockIdentityProvider( - mockSignUpResponse: { _ in - return .init( - codeDeliveryDetails: nil, - userConfirmed: true, - userSub: sub - ) - } - ) - - let result = try await plugin.signUp( - username: "foo", - password: "bar", - options: nil - ) - - XCTAssertEqual(result.nextStep, .done) - XCTAssertEqual(result.userID, sub) - XCTAssertTrue(result.isSignUpComplete) - } - - /// Given: A response from Cognito SignUp that includes `codeDeliveryDetails` where `userConfirmed == false` - /// When: Invoking `signUp(username:password:options:)` - /// Then: The caller should receive an `AuthSignUpResult` where `nextStep == .confirmUser` and - /// the applicable associated value of that case and the `userID` both equal the `userSub` returned by the service. - func test_signUp_confirmUser_userIDsMatch() async throws { - let sub = UUID().uuidString - mockIdentityProvider = MockIdentityProvider( - mockSignUpResponse: { _ in - return .init( - codeDeliveryDetails: .init( - attributeName: "some attribute", - deliveryMedium: .email, - destination: "" - ), - userConfirmed: false, - userSub: sub - ) - } - ) - - let result = try await plugin.signUp( - username: "foo", - password: "bar", - options: nil - ) - - guard case .confirmUser(_, _, let userID) = result.nextStep else { - return XCTFail("expected .confirmUser nextStep") - } - XCTAssertEqual(result.userID, userID) - } - func testSignUpServiceError() async { let errorsToTest: [(signUpOutputError: SignUpOutputError, cognitoError: AWSCognitoAuthError)] = [ diff --git a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignUp/AWSAuthSignUpTaskTests.swift b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignUp/AWSAuthSignUpTaskTests.swift index 4368f834f5..b739ca8ef6 100644 --- a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignUp/AWSAuthSignUpTaskTests.swift +++ b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignUp/AWSAuthSignUpTaskTests.swift @@ -41,7 +41,7 @@ class AWSAuthSignUpTaskTests: XCTestCase { let task = AWSAuthSignUpTask(request, authEnvironment: authEnvironment) let signUpResult = try await task.value print("Sign Up Result: \(signUpResult)") - await fulfillment(of: [functionExpectation], timeout: 1) + wait(for: [functionExpectation], timeout: 1) } /// Given: Configured AuthState machine