Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ struct RefreshUserPoolTokens: Action {

guard let authenticationResult = response?.authenticationResult,
let idToken = authenticationResult.idToken,
let accessToken = authenticationResult.accessToken,
let refreshToken = authenticationResult.refreshToken
let accessToken = authenticationResult.accessToken
else {
let event = RefreshSessionEvent(eventType: .throwError(.invalidTokens))
await dispatcher.send(event)
Expand All @@ -74,7 +73,7 @@ struct RefreshUserPoolTokens: Action {
let userPoolTokens = AWSCognitoUserPoolTokens(
idToken: idToken,
accessToken: accessToken,
refreshToken: refreshToken
refreshToken: authenticationResult.refreshToken ?? existingTokens.refreshToken
)

let signedInData = SignedInData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,43 +185,6 @@ class RefreshUserPoolTokensTests: XCTestCase {
userPoolFactory: identityProviderFactory)
)

await fulfillment(
of: [expectation],
timeout: 0.1
)
}
func testRefreshTokenMissing() async {

let expectation = expectation(description: "refreshTokenMissing")
let identityProviderFactory: BasicSRPAuthEnvironment.CognitoUserPoolFactory = {
MockIdentityProvider(
mockGetTokensFromRefreshTokenResponse: { _ in
return GetTokensFromRefreshTokenOutput(
authenticationResult: .init(
accessToken: "accessTokenNew",
expiresIn: 100,
idToken: "idTokenNew",
refreshToken: nil))
}
)
}

let action = RefreshUserPoolTokens(existingSignedIndata: .testData)

await action.execute(
withDispatcher: MockDispatcher { event in

if let userPoolEvent = event as? RefreshSessionEvent,
case let .throwError(error) = userPoolEvent.eventType
{
XCTAssertEqual(error, .invalidTokens)
expectation.fulfill()
}
},
environment: Defaults.makeDefaultAuthEnvironment(
userPoolFactory: identityProviderFactory)
)

await fulfillment(
of: [expectation],
timeout: 0.1
Expand Down
Loading