Skip to content

Commit

Permalink
Fix the unit test build
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisabhash committed Nov 29, 2023
1 parent e7752e4 commit 701fbbc
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public struct URLSessionClient: URLSessionClientBehavior {
for request: URLRequest,
delegate: (URLSessionTaskDelegate)?)
async throws -> (Data, URLResponse) {
if #available(iOS 15.0, *) {
if #available(iOS 15.0, macOS 12.0, tvOS 15.0, *) {
return try await self.urlSession.data(
for: request,
delegate: delegate
Expand Down Expand Up @@ -57,7 +57,7 @@ public struct URLSessionClient: URLSessionClientBehavior {
from url: URL,
delegate: (URLSessionTaskDelegate)?)
async throws -> (Data, URLResponse) {
if #available(iOS 15.0, *) {
if #available(iOS 15.0, macOS 12.0, tvOS 15.0, *) {
return try await self.urlSession.data(
from: url,
delegate: delegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ enum Defaults {
static func makeCredentialStoreOperationBehavior() -> CredentialStoreStateBehavior {
return MockCredentialStoreOperationClient()
}

static func makeURLSession() -> URLSession {
let configuration = URLSessionConfiguration.default
configuration.urlCache = nil
return URLSession(configuration: configuration)
}

static func makeDefaultUserPool() throws -> CognitoUserPoolBehavior {
return try CognitoIdentityProviderClient(region: regionString)
Expand Down Expand Up @@ -162,6 +168,7 @@ enum Defaults {
authenticationEnvironment: authenticationEnvironment,
authorizationEnvironment: authZEnvironment ?? authorizationEnvironment,
credentialsClient: makeCredentialStoreOperationBehavior(),
urlSessionClient: URLSessionClient(urlSession: makeURLSession()),
logger: Amplify.Logging.logger(forCategory: "awsCognitoAuthPluginTest")
)
Amplify.Logging.logLevel = .verbose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ class AuthenticationProviderConfirmSigninTests: BasePluginTest {
authenticationEnvironment: nil,
authorizationEnvironment: authorizationEnvironment,
credentialsClient: Defaults.makeCredentialStoreOperationBehavior(),
urlSessionClient: nil,
logger: Amplify.Logging.logger(forCategory: "awsCognitoAuthPluginTest")
)
let stateMachine = Defaults.authStateMachineWith(environment: environment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ class ConfirmSignInTOTPTaskTests: BasePluginTest {
authenticationEnvironment: nil,
authorizationEnvironment: authorizationEnvironment,
credentialsClient: Defaults.makeCredentialStoreOperationBehavior(),
urlSessionClient: nil,
logger: Amplify.Logging.logger(forCategory: "awsCognitoAuthPluginTest")
)
let stateMachine = Defaults.authStateMachineWith(environment: environment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ class ConfirmSignInWithMFASelectionTaskTests: BasePluginTest {
authenticationEnvironment: nil,
authorizationEnvironment: authorizationEnvironment,
credentialsClient: Defaults.makeCredentialStoreOperationBehavior(),
urlSessionClient: nil,
logger: Amplify.Logging.logger(forCategory: "awsCognitoAuthPluginTest")
)
let stateMachine = Defaults.authStateMachineWith(environment: environment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ class ConfirmSignInWithSetUpMFATaskTests: BasePluginTest {
authenticationEnvironment: nil,
authorizationEnvironment: authorizationEnvironment,
credentialsClient: Defaults.makeCredentialStoreOperationBehavior(),
urlSessionClient: nil,
logger: Amplify.Logging.logger(forCategory: "awsCognitoAuthPluginTest")
)
let stateMachine = Defaults.authStateMachineWith(environment: environment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ struct MockedAuthCognitoPluginHelper {
authenticationEnvironment: authenticationEnvironment,
authorizationEnvironment: nil,
credentialsClient: makeCredentialStoreClient(),
urlSessionClient: URLSessionClient(urlSession: makeURLSession()),
logger: log)

case .identityPools(let identityPoolConfigurationData):
Expand All @@ -136,6 +137,7 @@ struct MockedAuthCognitoPluginHelper {
authenticationEnvironment: nil,
authorizationEnvironment: authorizationEnvironment,
credentialsClient: makeCredentialStoreClient(),
urlSessionClient: URLSessionClient(urlSession: makeURLSession()),
logger: log)

case .userPoolsAndIdentityPools(let userPoolConfigurationData,
Expand All @@ -151,6 +153,7 @@ struct MockedAuthCognitoPluginHelper {
authenticationEnvironment: authenticationEnvironment,
authorizationEnvironment: authorizationEnvironment,
credentialsClient: makeCredentialStoreClient(),
urlSessionClient: URLSessionClient(urlSession: makeURLSession()),
logger: log)
}
}
Expand Down

0 comments on commit 701fbbc

Please sign in to comment.