Skip to content

Commit

Permalink
feat(Auth): Adding forceAliasCreation option during confirmSignUp (#3382
Browse files Browse the repository at this point in the history
)

* feat(Auth): Adding forceAliasCreation option during confirmSignUp

* update pinpoint unit tests

* Revert "update pinpoint unit tests"

This reverts commit 0f804d8.
  • Loading branch information
harsh62 authored Mar 18, 2024
1 parent e68b299 commit 9615f5a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ public struct AWSAuthConfirmSignUpOptions {

public let metadata: [String: String]?

public init(metadata: [String: String]? = nil) {
public let forceAliasCreation: Bool?

public init(metadata: [String: String]? = nil,
forceAliasCreation: Bool? = nil) {
self.metadata = metadata
self.forceAliasCreation = forceAliasCreation
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ extension ConfirmSignUpInput {
confirmationCode: String,
clientMetadata: [String: String]?,
asfDeviceId: String?,
forceAliasCreation: Bool?,
environment: UserPoolEnvironment
) {

Expand All @@ -37,6 +38,7 @@ extension ConfirmSignUpInput {
clientId: configuration.clientId,
clientMetadata: clientMetadata,
confirmationCode: confirmationCode,
forceAliasCreation: forceAliasCreation,
secretHash: secretHash,
userContextData: userContextData,
username: username)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ class AWSAuthConfirmSignUpTask: AuthConfirmSignUpTask, DefaultLogger {
for: request.username,
credentialStoreClient: authEnvironment.credentialsClient)
let metadata = (request.options.pluginOptions as? AWSAuthConfirmSignUpOptions)?.metadata
let forceAliasCreation = (request.options.pluginOptions as? AWSAuthConfirmSignUpOptions)?.forceAliasCreation
let client = try userPoolEnvironment.cognitoUserPoolFactory()
let input = ConfirmSignUpInput(username: request.username,
confirmationCode: request.code,
clientMetadata: metadata,
asfDeviceId: asfDeviceId,
forceAliasCreation: forceAliasCreation,
environment: userPoolEnvironment)
_ = try await client.confirmSignUp(input: input)
log.verbose("Received success")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ConfirmSignUpInputTests: XCTestCase {
confirmationCode: "123",
clientMetadata: [:],
asfDeviceId: "asdfDeviceId",
forceAliasCreation: nil,
environment: environment)

XCTAssertNotNil(confirmSignUpInput.secretHash)
Expand All @@ -55,6 +56,7 @@ class ConfirmSignUpInputTests: XCTestCase {
confirmationCode: "123",
clientMetadata: [:],
asfDeviceId: nil,
forceAliasCreation: nil,
environment: environment)

XCTAssertNil(confirmSignUpInput.secretHash)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class AWSAuthConfirmSignUpAPITests: BasePluginTest {
func testSuccessfulSignUp() async throws {

self.mockIdentityProvider = MockIdentityProvider(
mockConfirmSignUpResponse: { _ in
mockConfirmSignUpResponse: { request in
XCTAssertNil(request.clientMetadata)
XCTAssertNil(request.forceAliasCreation)
return .init()
}
)
Expand All @@ -47,11 +49,14 @@ class AWSAuthConfirmSignUpAPITests: BasePluginTest {
mockConfirmSignUpResponse: { request in
XCTAssertNotNil(request.clientMetadata)
XCTAssertEqual(request.clientMetadata?["key"], "value")
XCTAssertEqual(request.forceAliasCreation, true)
return .init()
}
)

let pluginOptions = AWSAuthConfirmSignUpOptions(metadata: ["key": "value"])
let pluginOptions = AWSAuthConfirmSignUpOptions(
metadata: ["key": "value"],
forceAliasCreation: true)
let options = AuthConfirmSignUpRequest.Options(pluginOptions: pluginOptions)
let result = try await self.plugin.confirmSignUp(
for: "jeffb",
Expand Down

0 comments on commit 9615f5a

Please sign in to comment.