Skip to content

Commit e6ca6e5

Browse files
committed
Adds unit tests for CTE with org param
1 parent cd8126d commit e6ca6e5

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Auth0Tests/AuthenticationSpec.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,7 @@ class AuthenticationSpec: QuickSpec {
19281928
describe("customTokenExchange") {
19291929
let subjectToken = "example-token"
19301930
let subjectTokenType = "urn:ietf:params:oauth:token-type:jwt"
1931+
let orgId = "org_id"
19311932

19321933
it("should exchange custom token for credentials") {
19331934
NetworkStub.addStub(condition: {
@@ -1974,6 +1975,29 @@ class AuthenticationSpec: QuickSpec {
19741975
}
19751976
}
19761977

1978+
it("should exchange custom token with organization") {
1979+
NetworkStub.addStub(condition: {
1980+
$0.isToken(Domain) && $0.hasAllOf([
1981+
"grant_type": TokenExchangeGrantType,
1982+
"subject_token": subjectToken,
1983+
"subject_token_type": subjectTokenType,
1984+
"scope": defaultScope,
1985+
"organization": orgId,
1986+
"client_id": ClientId
1987+
])
1988+
}, response: authResponse(accessToken: AccessToken, idToken: IdToken))
1989+
1990+
waitUntil(timeout: Timeout) { done in
1991+
auth.customTokenExchange(subjectToken: subjectToken,
1992+
subjectTokenType: subjectTokenType,
1993+
organization: orgId)
1994+
.start { result in
1995+
expect(result).to(haveCredentials(AccessToken, IdToken))
1996+
done()
1997+
}
1998+
}
1999+
}
2000+
19772001
it("should produce authentication error") {
19782002
let code = "invalid_grant"
19792003
let description = "Invalid subject token"

0 commit comments

Comments
 (0)