Skip to content

Commit d7415a4

Browse files
committed
updated further tests to use new API as well as auth hub event handler tests
1 parent 9f81731 commit d7415a4

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/HubEventTests/AuthHubEventHandlerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ class AuthHubEventHandlerTests: XCTestCase {
423423
.notStarted)
424424

425425
let mockIdentityProvider = MockIdentityProvider(
426-
mockInitiateAuthResponse: { _ in
426+
mockGetTokensFromRefreshTokenResponse: { _ in
427427
throw AWSCognitoIdentityProvider.NotAuthorizedException()
428428
})
429429

AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/AuthorizationTests/AWSAuthFetchSignInSessionOperationTests.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -494,15 +494,15 @@ class AWSAuthFetchSignInSessionOperationTests: BaseAuthorizationTests {
494494
AmplifyCredentials.testDataWithExpiredTokens),
495495
.notStarted)
496496

497-
let initAuth: MockIdentityProvider.MockInitiateAuthResponse = { _ in
498-
return InitiateAuthOutput(authenticationResult: .init(accessToken: nil,
497+
let refreshTokenAuth: MockIdentityProvider.MockGetTokensFromRefreshTokenResponse = { _ in
498+
return GetTokensFromRefreshTokenOutput(authenticationResult: .init(accessToken: nil,
499499
expiresIn: 1000,
500500
idToken: "idToken",
501501
refreshToken: "refreshToke"))
502502
}
503503

504504
let plugin = configurePluginWith(
505-
userPool: { MockIdentityProvider(mockInitiateAuthResponse: initAuth) },
505+
userPool: { MockIdentityProvider(mockGetTokensFromRefreshTokenResponse: refreshTokenAuth) },
506506
initialState: initialState)
507507

508508
let session = try await plugin.fetchAuthSession(options: AuthFetchSessionRequest.Options())
@@ -548,8 +548,8 @@ class AWSAuthFetchSignInSessionOperationTests: BaseAuthorizationTests {
548548
AmplifyCredentials.testDataWithExpiredTokens),
549549
.notStarted)
550550

551-
let initAuth: MockIdentityProvider.MockInitiateAuthResponse = { _ in
552-
return InitiateAuthOutput(authenticationResult: .init(accessToken: "accessToken",
551+
let refreshTokenAuth: MockIdentityProvider.MockGetTokensFromRefreshTokenResponse = { _ in
552+
return GetTokensFromRefreshTokenOutput(authenticationResult: .init(accessToken: "accessToken",
553553
expiresIn: 1000,
554554
idToken: "idToken",
555555
refreshToken: "refreshToke"))
@@ -559,7 +559,7 @@ class AWSAuthFetchSignInSessionOperationTests: BaseAuthorizationTests {
559559
return GetCredentialsForIdentityOutput(credentials: nil, identityId: "ss")
560560
}
561561
let plugin = configurePluginWith(
562-
userPool: { MockIdentityProvider(mockInitiateAuthResponse: initAuth) },
562+
userPool: { MockIdentityProvider(mockGetTokensFromRefreshTokenResponse: refreshTokenAuth) },
563563
identityPool: { MockIdentity(mockGetCredentialsResponse: awsCredentials) },
564564
initialState: initialState)
565565

@@ -714,12 +714,12 @@ class AWSAuthFetchSignInSessionOperationTests: BaseAuthorizationTests {
714714
AmplifyCredentials.testDataWithExpiredTokens),
715715
.notStarted)
716716

717-
let initAuth: MockIdentityProvider.MockInitiateAuthResponse = { _ in
717+
let refreshTokenAuth: MockIdentityProvider.MockGetTokensFromRefreshTokenResponse = { _ in
718718
throw AWSCognitoIdentityProvider.NotAuthorizedException(message: "NotAuthorized")
719719
}
720720

721721
let plugin = configurePluginWith(
722-
userPool: { MockIdentityProvider(mockInitiateAuthResponse: initAuth) },
722+
userPool: { MockIdentityProvider(mockGetTokensFromRefreshTokenResponse: refreshTokenAuth) },
723723
initialState: initialState)
724724

725725
let session = try await plugin.fetchAuthSession(options: AuthFetchSessionRequest.Options())
@@ -816,8 +816,8 @@ class AWSAuthFetchSignInSessionOperationTests: BaseAuthorizationTests {
816816
AmplifyCredentials.testDataWithExpiredTokens),
817817
.notStarted)
818818

819-
let initAuth: MockIdentityProvider.MockInitiateAuthResponse = { _ in
820-
return InitiateAuthOutput(authenticationResult: .init(accessToken: "accessToken",
819+
let refreshTokenAuth: MockIdentityProvider.MockGetTokensFromRefreshTokenResponse = { _ in
820+
return GetTokensFromRefreshTokenOutput(authenticationResult: .init(accessToken: "accessToken",
821821
expiresIn: 1000,
822822
idToken: "idToken",
823823
refreshToken: "refreshToke"))
@@ -827,7 +827,7 @@ class AWSAuthFetchSignInSessionOperationTests: BaseAuthorizationTests {
827827
throw NSError(domain: NSURLErrorDomain, code: 1, userInfo: nil)
828828
}
829829
let plugin = configurePluginWith(
830-
userPool: { MockIdentityProvider(mockInitiateAuthResponse: initAuth) },
830+
userPool: { MockIdentityProvider(mockGetTokensFromRefreshTokenResponse: refreshTokenAuth) },
831831
identityPool: { MockIdentity(mockGetCredentialsResponse: awsCredentials) },
832832
initialState: initialState)
833833

0 commit comments

Comments
 (0)