Skip to content

Commit

Permalink
Adding unit tests for duo
Browse files Browse the repository at this point in the history
  • Loading branch information
sameh0 committed Nov 16, 2023
1 parent 7a0a738 commit ec89516
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Tests/OktaIdxTests/IDXClientV1ResponseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -748,4 +748,45 @@ class IDXClientV1ResponseTests: XCTestCase {
XCTAssertEqual(firstAuthenticator.profile?["email"], "t***[email protected]")
XCTAssertEqual(secondAuthenticator.profile?["email"], "e***[email protected]")
}

func testDuoCapability() throws {
let host = "api.duosecurity.com"
let token = "token"
let script = "Duo-Web-v2.6.js"

let obj = try decode(type: IonObject<IonAuthenticator>.self, """
{
"type" : "object",
"value" : {
"contextualData": {
"integrationType": "IFRAME",
"host": "\(host)",
"signedToken": "\(token)",
"script": "\(script)"
},
"type": "app",
"key": "duo",
"id": "dsfd21pa9uqQZMcJL5d7",
"displayName": "Duo Security",
"methods": [
{
"type": "duo"
}
]
}
}
""")

let publicObj = try XCTUnwrap(Authenticator.makeAuthenticator(flow: flowMock,
ion: [obj.value],
jsonPaths: [],
in: response))
XCTAssertEqual(publicObj.type, .app)
let otp = try XCTUnwrap(publicObj.duo)

XCTAssertEqual(otp.host, host)
XCTAssertEqual(otp.signedToken, token)
XCTAssertNotNil(otp.script, script)
}

}

0 comments on commit ec89516

Please sign in to comment.