From 316d580998c05b694869a5a4a7e29101da3ad5f9 Mon Sep 17 00:00:00 2001 From: Abhash Kumar Singh Date: Wed, 29 Nov 2023 12:06:52 -0800 Subject: [PATCH] Address review comments --- .../AWSCognitoAuthPlugin+Configure.swift | 12 +-- .../Environment/AuthEnvironment.swift | 2 +- .../AWSPreInitiateAuthSignUpBehavior.swift | 79 +++++++++++++++++ .../PreInitiateAuthSignUpBehavior.swift | 19 ++++ .../PreInitiateAuthSignUpPayload.swift} | 2 +- .../URLSessionClient/URLSessionClient.swift | 87 ------------------- .../URLSessionClientBehavior.swift | 27 ------ .../MockPreInitiateAuthSignUpBehavior.swift | 24 +++++ .../Mocks/MockURLSessionClient.swift | 31 ------- .../Support/DefaultConfig.swift | 2 +- .../AWSAuthConfirmSignInTaskTests.swift | 2 +- .../SignIn/ConfirmSignInTOTPTaskTests.swift | 2 +- ...nfirmSignInWithMFASelectionTaskTests.swift | 2 +- .../ConfirmSignInWithSetUpMFATaskTests.swift | 2 +- .../Mocks/MockedAuthCognitoPlugin.swift | 6 +- 15 files changed, 138 insertions(+), 161 deletions(-) create mode 100644 AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/Passwordless/AWSPreInitiateAuthSignUpBehavior.swift create mode 100644 AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/Passwordless/PreInitiateAuthSignUpBehavior.swift rename AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/{URLSessionClient/PreInitiateAuthPayload.swift => Passwordless/PreInitiateAuthSignUpPayload.swift} (94%) delete mode 100644 AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/URLSessionClient/URLSessionClient.swift delete mode 100644 AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/URLSessionClient/URLSessionClientBehavior.swift create mode 100644 AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Mocks/MockPreInitiateAuthSignUpBehavior.swift delete mode 100644 AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Mocks/MockURLSessionClient.swift diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/AWSCognitoAuthPlugin+Configure.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/AWSCognitoAuthPlugin+Configure.swift index c9742a5457..6352ccecc7 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/AWSCognitoAuthPlugin+Configure.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/AWSCognitoAuthPlugin+Configure.swift @@ -42,13 +42,13 @@ extension AWSCognitoAuthPlugin { let credentialsClient = CredentialStoreOperationClient( credentialStoreStateMachine: credentialStoreMachine) - let urlSessionClient = URLSessionClient(urlSession: makeURLSession()) + let preInitiateAuthSignUpClient = AWSPreInitiateAuthSignUpBehavior(urlSession: makeURLSession()) let authResolver = AuthState.Resolver().eraseToAnyResolver() let authEnvironment = makeAuthEnvironment( authConfiguration: authConfiguration, credentialsClient: credentialsClient, - urlSessionClient: urlSessionClient + preInitiateAuthSignUpClient: preInitiateAuthSignUpClient ) let authStateMachine = StateMachine(resolver: authResolver, environment: authEnvironment) @@ -158,7 +158,7 @@ extension AWSCognitoAuthPlugin { private func makeAuthEnvironment( authConfiguration: AuthConfiguration, credentialsClient: CredentialStoreStateBehavior, - urlSessionClient: URLSessionClientBehavior + preInitiateAuthSignUpClient: PreInitiateAuthSignUpBehavior ) -> AuthEnvironment { switch authConfiguration { @@ -173,7 +173,7 @@ extension AWSCognitoAuthPlugin { authenticationEnvironment: authenticationEnvironment, authorizationEnvironment: nil, credentialsClient: credentialsClient, - urlSessionClient: urlSessionClient, + preInitiateAuthSignUpClient: preInitiateAuthSignUpClient, logger: log) case .identityPools(let identityPoolConfigurationData): @@ -186,7 +186,7 @@ extension AWSCognitoAuthPlugin { authenticationEnvironment: nil, authorizationEnvironment: authorizationEnvironment, credentialsClient: credentialsClient, - urlSessionClient: urlSessionClient, + preInitiateAuthSignUpClient: preInitiateAuthSignUpClient, logger: log) case .userPoolsAndIdentityPools(let userPoolConfigurationData, @@ -202,7 +202,7 @@ extension AWSCognitoAuthPlugin { authenticationEnvironment: authenticationEnvironment, authorizationEnvironment: authorizationEnvironment, credentialsClient: credentialsClient, - urlSessionClient: urlSessionClient, + preInitiateAuthSignUpClient: preInitiateAuthSignUpClient, logger: log) } } diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Environment/AuthEnvironment.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Environment/AuthEnvironment.swift index 21ccbb039d..90cd862cb7 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Environment/AuthEnvironment.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Environment/AuthEnvironment.swift @@ -15,7 +15,7 @@ struct AuthEnvironment: Environment, LoggerProvider { let authenticationEnvironment: AuthenticationEnvironment? let authorizationEnvironment: AuthorizationEnvironment? let credentialsClient: CredentialStoreStateBehavior - let urlSessionClient: URLSessionClientBehavior? + let preInitiateAuthSignUpClient: PreInitiateAuthSignUpBehavior? let logger: Logger } diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/Passwordless/AWSPreInitiateAuthSignUpBehavior.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/Passwordless/AWSPreInitiateAuthSignUpBehavior.swift new file mode 100644 index 0000000000..ced2b927c3 --- /dev/null +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/Passwordless/AWSPreInitiateAuthSignUpBehavior.swift @@ -0,0 +1,79 @@ +// +// Copyright Amazon.com Inc. or its affiliates. +// All Rights Reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// + +import Foundation +import Amplify +import AWSPluginsCore + +/// Concrete implementation of PreInitiateAuthSignUpBehavior +class AWSPreInitiateAuthSignUpBehavior : PreInitiateAuthSignUpBehavior { + + let urlSession: URLSession + let userAgent: String + + init(urlSession: URLSession) { + self.urlSession = urlSession + self.userAgent = "\(AmplifyAWSServiceConfiguration.userAgentLib) \(AmplifyAWSServiceConfiguration.userAgentOS)" + } + + func preInitiateAuthSignUp(preInitiateAuthSignUpEndpoint: URL, + preInitiateAuthSignUpPayload: PreInitiateAuthSignUpPayload) async throws -> Result { + + var request = URLRequest(url: preInitiateAuthSignUpEndpoint) + request.httpMethod = "POST" + request.setValue(userAgent, forHTTPHeaderField: "User-Agent") + + do { + let (_, response) = try await self.data(for: request) + + guard let response = response as? HTTPURLResponse else { + throw AuthError.unknown("Response received is not a HTTPURLResponse") + } + + if response.statusCode == 200 { + return .successfulVoid + } else { + throw AuthError.unknown("Response received with status code: \(response.statusCode)") + } + } catch { + throw AuthError.service(error.localizedDescription, + "API Gateway returned an error. Please check the error message for more details.", + error) + } + } + + private func data( + for request: URLRequest, + delegate: (URLSessionTaskDelegate)? = nil) + async throws -> (Data, URLResponse) { + if #available(iOS 15.0, macOS 12.0, tvOS 15.0, *) { + return try await self.urlSession.data( + for: request, + delegate: delegate + ) + } else { + // Fallback on earlier versions + return try await withCheckedThrowingContinuation({ continuation in + let dataTask = urlSession.dataTask(with: request) { data, response, error in + if let data = data, let response = response { + continuation.resume(returning: (data, response)) + } else { + continuation.resume(throwing: error ?? AuthError.unknown( + """ + An unknown error occurred with + data: \(String(describing: data)) + response: \(String(describing: response)) + error: \(String(describing: error)) + """) + ) + } + } + dataTask.resume() + }) + } + } +} diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/Passwordless/PreInitiateAuthSignUpBehavior.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/Passwordless/PreInitiateAuthSignUpBehavior.swift new file mode 100644 index 0000000000..6d3ff543e6 --- /dev/null +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/Passwordless/PreInitiateAuthSignUpBehavior.swift @@ -0,0 +1,19 @@ +// +// Copyright Amazon.com Inc. or its affiliates. +// All Rights Reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// + +import Foundation +import Amplify + +// Protocol for initiating sign up in a passwordless flow +protocol PreInitiateAuthSignUpBehavior { + + func preInitiateAuthSignUp( + preInitiateAuthSignUpEndpoint: URL, + preInitiateAuthSignUpPayload: PreInitiateAuthSignUpPayload) + async throws -> Result + +} diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/URLSessionClient/PreInitiateAuthPayload.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/Passwordless/PreInitiateAuthSignUpPayload.swift similarity index 94% rename from AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/URLSessionClient/PreInitiateAuthPayload.swift rename to AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/Passwordless/PreInitiateAuthSignUpPayload.swift index c9698c6a3a..d90e854874 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/URLSessionClient/PreInitiateAuthPayload.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/Passwordless/PreInitiateAuthSignUpPayload.swift @@ -9,7 +9,7 @@ import Foundation // Payload data structure to send to the API Gateway endpoint // for password sign up and sign in flow to initiate creating a new user -struct PreInitiateAuthPayload: Codable { +struct PreInitiateAuthSignUpPayload: Codable { let username: String let deliveryMedium: String let userAttributes: [String:String]? diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/URLSessionClient/URLSessionClient.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/URLSessionClient/URLSessionClient.swift deleted file mode 100644 index ee1d90b0e2..0000000000 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/URLSessionClient/URLSessionClient.swift +++ /dev/null @@ -1,87 +0,0 @@ -// -// Copyright Amazon.com Inc. or its affiliates. -// All Rights Reserved. -// -// SPDX-License-Identifier: Apache-2.0 -// - -import Foundation -import Amplify - -// A delegate client for `URLSessionClientBehavior` -public struct URLSessionClient: URLSessionClientBehavior { - - let urlSession: URLSession - - public init(urlSession: URLSession) { - self.urlSession = urlSession - } - - public func cancelAndReset() async { - self.urlSession.invalidateAndCancel() - await self.urlSession.reset() - } - - public func data( - for request: URLRequest, - delegate: (URLSessionTaskDelegate)?) - async throws -> (Data, URLResponse) { - if #available(iOS 15.0, macOS 12.0, tvOS 15.0, *) { - return try await self.urlSession.data( - for: request, - delegate: delegate - ) - } else { - // Fallback on earlier versions - return try await withCheckedThrowingContinuation({ continuation in - let dataTask = urlSession.dataTask(with: request) { data, response, error in - if let data = data, let response = response { - continuation.resume(returning: (data, response)) - } else { - continuation.resume(throwing: error ?? AuthError.unknown( - """ - An unknown error occurred with - data: \(String(describing: data)) - response: \(String(describing: response)) - error: \(String(describing: error)) - """) - ) - } - } - dataTask.resume() - }) - } - } - - public func data( - from url: URL, - delegate: (URLSessionTaskDelegate)?) - async throws -> (Data, URLResponse) { - if #available(iOS 15.0, macOS 12.0, tvOS 15.0, *) { - return try await self.urlSession.data( - from: url, - delegate: delegate - ) - } else { - // Fallback on earlier versions - return try await withCheckedThrowingContinuation({ continuation in - let dataTask = urlSession.dataTask(with: url) { data, response, error in - if let data = data, let response = response { - continuation.resume(returning: (data, response)) - } else { - continuation.resume(throwing: error ?? AuthError.unknown( - """ - An unknown error occurred with - data: \(String(describing: data)) - response: \(String(describing: response)) - error: \(String(describing: error)) - """) - ) - } - } - dataTask.resume() - }) - } - } - -} diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/URLSessionClient/URLSessionClientBehavior.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/URLSessionClient/URLSessionClientBehavior.swift deleted file mode 100644 index be43b82ee5..0000000000 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/URLSessionClient/URLSessionClientBehavior.swift +++ /dev/null @@ -1,27 +0,0 @@ -// -// Copyright Amazon.com Inc. or its affiliates. -// All Rights Reserved. -// -// SPDX-License-Identifier: Apache-2.0 -// - -import Foundation - -// Protocol for replicating `URLSession` behavior -// Note: Additional behavior can be added later if necessary -public protocol URLSessionClientBehavior { - - /// For testing only. Resets the state of the object in preparation for testing. - func cancelAndReset() async - - func data( - for request: URLRequest, - delegate: (URLSessionTaskDelegate)? - ) async throws -> (Data, URLResponse) - - func data( - from url: URL, - delegate: (URLSessionTaskDelegate)? - ) async throws -> (Data, URLResponse) - -} diff --git a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Mocks/MockPreInitiateAuthSignUpBehavior.swift b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Mocks/MockPreInitiateAuthSignUpBehavior.swift new file mode 100644 index 0000000000..aa2048b6e1 --- /dev/null +++ b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Mocks/MockPreInitiateAuthSignUpBehavior.swift @@ -0,0 +1,24 @@ +// +// Copyright Amazon.com Inc. or its affiliates. +// All Rights Reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// + +import Foundation +import Amplify +@testable import AWSPluginsCore +@testable import AWSCognitoAuthPlugin + +class MockPreInitiateAuthSignUpBehavior: PreInitiateAuthSignUpBehavior { + + public var preInitiateAuthSignUpCallCount = 0 + + func preInitiateAuthSignUp( + preInitiateAuthSignUpEndpoint: URL, + preInitiateAuthSignUpPayload: PreInitiateAuthSignUpPayload) + async throws -> Result { + preInitiateAuthSignUpCallCount += 1 + return .successfulVoid + } +} diff --git a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Mocks/MockURLSessionClient.swift b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Mocks/MockURLSessionClient.swift deleted file mode 100644 index 744105ed4d..0000000000 --- a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Mocks/MockURLSessionClient.swift +++ /dev/null @@ -1,31 +0,0 @@ -// -// Copyright Amazon.com Inc. or its affiliates. -// All Rights Reserved. -// -// SPDX-License-Identifier: Apache-2.0 -// - -import Foundation -@testable import AWSCognitoAuthPlugin - -class MockURLSessionClient: URLSessionClientBehavior { - - public var cancelAndResetCallCount = 0 - public var dataForURLRequestCallCount = 0 - public var dataForURLCallCount = 0 - - func cancelAndReset() async { - cancelAndResetCallCount += 1 - } - - func data(for request: URLRequest, delegate: (URLSessionTaskDelegate)?) async throws -> (Data, URLResponse) { - dataForURLRequestCallCount += 1 - return (Data(), HTTPURLResponse()) - } - - func data(from url: URL, delegate: (URLSessionTaskDelegate)?) async throws -> (Data, URLResponse) { - dataForURLCallCount += 1 - return (Data(), HTTPURLResponse()) - } - -} diff --git a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Support/DefaultConfig.swift b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Support/DefaultConfig.swift index 175f60e441..3c6b0d8c97 100644 --- a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Support/DefaultConfig.swift +++ b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Support/DefaultConfig.swift @@ -168,7 +168,7 @@ enum Defaults { authenticationEnvironment: authenticationEnvironment, authorizationEnvironment: authZEnvironment ?? authorizationEnvironment, credentialsClient: makeCredentialStoreOperationBehavior(), - urlSessionClient: URLSessionClient(urlSession: makeURLSession()), + preInitiateAuthSignUpClient: AWSPreInitiateAuthSignUpBehavior(urlSession: makeURLSession()), logger: Amplify.Logging.logger(forCategory: "awsCognitoAuthPluginTest") ) Amplify.Logging.logLevel = .verbose diff --git a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/AWSAuthConfirmSignInTaskTests.swift b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/AWSAuthConfirmSignInTaskTests.swift index 66090b4bd1..a6d53b5111 100644 --- a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/AWSAuthConfirmSignInTaskTests.swift +++ b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/AWSAuthConfirmSignInTaskTests.swift @@ -494,7 +494,7 @@ class AuthenticationProviderConfirmSigninTests: BasePluginTest { authenticationEnvironment: nil, authorizationEnvironment: authorizationEnvironment, credentialsClient: Defaults.makeCredentialStoreOperationBehavior(), - urlSessionClient: nil, + preInitiateAuthSignUpClient: nil, logger: Amplify.Logging.logger(forCategory: "awsCognitoAuthPluginTest") ) let stateMachine = Defaults.authStateMachineWith(environment: environment, diff --git a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/ConfirmSignInTOTPTaskTests.swift b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/ConfirmSignInTOTPTaskTests.swift index 38d99bdf57..6e81a5b701 100644 --- a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/ConfirmSignInTOTPTaskTests.swift +++ b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/ConfirmSignInTOTPTaskTests.swift @@ -512,7 +512,7 @@ class ConfirmSignInTOTPTaskTests: BasePluginTest { authenticationEnvironment: nil, authorizationEnvironment: authorizationEnvironment, credentialsClient: Defaults.makeCredentialStoreOperationBehavior(), - urlSessionClient: nil, + preInitiateAuthSignUpClient: nil, logger: Amplify.Logging.logger(forCategory: "awsCognitoAuthPluginTest") ) let stateMachine = Defaults.authStateMachineWith(environment: environment, diff --git a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/ConfirmSignInWithMFASelectionTaskTests.swift b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/ConfirmSignInWithMFASelectionTaskTests.swift index 11805b3f4b..22ea623f47 100644 --- a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/ConfirmSignInWithMFASelectionTaskTests.swift +++ b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/ConfirmSignInWithMFASelectionTaskTests.swift @@ -548,7 +548,7 @@ class ConfirmSignInWithMFASelectionTaskTests: BasePluginTest { authenticationEnvironment: nil, authorizationEnvironment: authorizationEnvironment, credentialsClient: Defaults.makeCredentialStoreOperationBehavior(), - urlSessionClient: nil, + preInitiateAuthSignUpClient: nil, logger: Amplify.Logging.logger(forCategory: "awsCognitoAuthPluginTest") ) let stateMachine = Defaults.authStateMachineWith(environment: environment, diff --git a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/ConfirmSignInWithSetUpMFATaskTests.swift b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/ConfirmSignInWithSetUpMFATaskTests.swift index f60723bdb7..7d1a52ca03 100644 --- a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/ConfirmSignInWithSetUpMFATaskTests.swift +++ b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/ConfirmSignInWithSetUpMFATaskTests.swift @@ -311,7 +311,7 @@ class ConfirmSignInWithSetUpMFATaskTests: BasePluginTest { authenticationEnvironment: nil, authorizationEnvironment: authorizationEnvironment, credentialsClient: Defaults.makeCredentialStoreOperationBehavior(), - urlSessionClient: nil, + preInitiateAuthSignUpClient: nil, logger: Amplify.Logging.logger(forCategory: "awsCognitoAuthPluginTest") ) let stateMachine = Defaults.authStateMachineWith(environment: environment, diff --git a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TestHarness/Mocks/MockedAuthCognitoPlugin.swift b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TestHarness/Mocks/MockedAuthCognitoPlugin.swift index d084e53114..7cb8d0140c 100644 --- a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TestHarness/Mocks/MockedAuthCognitoPlugin.swift +++ b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TestHarness/Mocks/MockedAuthCognitoPlugin.swift @@ -124,7 +124,7 @@ struct MockedAuthCognitoPluginHelper { authenticationEnvironment: authenticationEnvironment, authorizationEnvironment: nil, credentialsClient: makeCredentialStoreClient(), - urlSessionClient: URLSessionClient(urlSession: makeURLSession()), + preInitiateAuthSignUpClient: AWSPreInitiateAuthSignUpBehavior(urlSession: makeURLSession()), logger: log) case .identityPools(let identityPoolConfigurationData): @@ -137,7 +137,7 @@ struct MockedAuthCognitoPluginHelper { authenticationEnvironment: nil, authorizationEnvironment: authorizationEnvironment, credentialsClient: makeCredentialStoreClient(), - urlSessionClient: URLSessionClient(urlSession: makeURLSession()), + preInitiateAuthSignUpClient: AWSPreInitiateAuthSignUpBehavior(urlSession: makeURLSession()), logger: log) case .userPoolsAndIdentityPools(let userPoolConfigurationData, @@ -153,7 +153,7 @@ struct MockedAuthCognitoPluginHelper { authenticationEnvironment: authenticationEnvironment, authorizationEnvironment: authorizationEnvironment, credentialsClient: makeCredentialStoreClient(), - urlSessionClient: URLSessionClient(urlSession: makeURLSession()), + preInitiateAuthSignUpClient: AWSPreInitiateAuthSignUpBehavior(urlSession: makeURLSession()), logger: log) } }