Skip to content

Commit

Permalink
Merge pull request #158 from santhoshramaraju-okta/sr-okta-bindingCod…
Browse files Browse the repository at this point in the history
…eSupport

Fixing tests
  • Loading branch information
mikenachbaur-okta authored Nov 16, 2023
2 parents b808e61 + c30cdeb commit bc06458
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
24 changes: 12 additions & 12 deletions Tests/OktaDirectAuthTests/FactorStepHandlerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ final class FactorStepHandlerTests: XCTestCase {
loginHint: "jane.doe@example.com",
factor: factor)

let wait = expectation(description: "process")
let processExpectation = expectation(description: "process")
handler.process { result in
guard case .success(let status) = result,
case .bindingUpdate(let context) = status else {
Expand All @@ -282,9 +282,9 @@ final class FactorStepHandlerTests: XCTestCase {
}
}
XCTAssertEqual(context.oobResponse.oobCode, "1c266114-a1be-4252-8ad1-04986c5b9ac1")
wait.fulfill()
processExpectation.fulfill()
}
waitForExpectations(timeout: 5)
wait(for: [processExpectation], timeout: 5)
}

func testPrimaryOOBBindingTransferFail() throws {
Expand All @@ -305,17 +305,17 @@ final class FactorStepHandlerTests: XCTestCase {
loginHint: "jane.doe@example.com",
factor: factor)

let wait = expectation(description: "process")
let processExpectation = expectation(description: "process")
handler.process { result in
switch result {
case .success(_):
XCTFail("Not expecting success")
case .failure(let error):
XCTAssertEqual(error, .bindingCodeMissing)
}
wait.fulfill()
processExpectation.fulfill()
}
waitForExpectations(timeout: 5)
wait(for: [processExpectation], timeout: 5)
}

func testPrimaryOOBMFARequired() throws {
Expand Down Expand Up @@ -411,7 +411,7 @@ final class FactorStepHandlerTests: XCTestCase {
mfaToken: "abcd1234")),
factor: factor)

let wait = expectation(description: "process")
let processExpectation = expectation(description: "process")
handler.process { result in
guard case .success(let status) = result,
case .bindingUpdate(let context) = status else {
Expand All @@ -432,9 +432,9 @@ final class FactorStepHandlerTests: XCTestCase {
}
}
XCTAssertEqual(context.oobResponse.oobCode, "1c266114-a1be-4252-8ad1-04986c5b9ac1")
wait.fulfill()
processExpectation.fulfill()
}
waitForExpectations(timeout: 5)
wait(for: [processExpectation], timeout: 5)
}

func testSecondaryOOBBindingTransferFail() throws {
Expand All @@ -456,17 +456,17 @@ final class FactorStepHandlerTests: XCTestCase {
mfaToken: "abcd1234")),
factor: factor)

let wait = expectation(description: "process")
let processExpectation = expectation(description: "process")
handler.process { result in
switch result {
case .success(_):
XCTFail("Not expecting success")
case .failure(let error):
XCTAssertEqual(error.errorDescription, DirectAuthenticationFlowError.bindingCodeMissing.errorDescription)
}
wait.fulfill()
processExpectation.fulfill()
}
waitForExpectations(timeout: 5)
wait(for: [processExpectation], timeout: 5)
}

private func assertGettingTokenAfterBindingTransfer(using handler: StepHandler) {
Expand Down
3 changes: 2 additions & 1 deletion Tests/OktaOAuth2Tests/OAuth2ClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ final class OAuth2ClientTests: XCTestCase {

func testExchangeFailed() throws {
let pkce = PKCE()
Token.idTokenValidator = MockIDTokenValidator(error: .invalidIssuer)
let (openIdConfiguration, openIdData) = try openIdConfiguration(named: "openid-configuration-invalid-issuer")
let clientConfiguration = try OAuth2Client.Configuration(domain: "example.com",
clientId: "client_id",
Expand Down Expand Up @@ -114,8 +115,8 @@ final class OAuth2ClientTests: XCTestCase {
return
}
XCTAssertEqual(invalidIssuer as? JWTError, JWTError.invalidIssuer)
expect.fulfill()
}
expect.fulfill()

waitForExpectations(timeout: 1.0) { error in
XCTAssertNil(error)
Expand Down

0 comments on commit bc06458

Please sign in to comment.