Skip to content

Commit

Permalink
Revert "feat(auth): add userID property to AuthSignUpResult (#3179)"
Browse files Browse the repository at this point in the history
This reverts commit 115407a.
  • Loading branch information
atierian authored Aug 30, 2023
1 parent 115407a commit f5a1af0
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 72 deletions.
8 changes: 1 addition & 7 deletions Amplify/Categories/Auth/Result/AuthSignUpResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f5a1af0

Please sign in to comment.