Skip to content

Commit

Permalink
test: added unit tests for capturing redirect url from authorize url …
Browse files Browse the repository at this point in the history
…in case of webviewprovider
  • Loading branch information
desusai7 committed Oct 9, 2024
1 parent 7e6135d commit bddf7a5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Auth0Tests/WebViewProviderSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class WebViewProviderSpec: QuickSpec {
var mockWebView: WKWebView!

let authorizeURL = URL(string: "https://auth0.com/authorize?redirect_uri=https://auth0.com/callback")!
let logoutURL = URL(string: "https://auth0.com/authorize?returnTo=https://auth0.com/callback")!
let redirectURL = URL(string: "https://auth0.com/callback")!
let customSchemeRedirectURL = URL(string: "customscheme://auth0.com/callback")!
let code = "abc123"
Expand Down Expand Up @@ -46,6 +47,18 @@ class WebViewProviderSpec: QuickSpec {
let userAgent = provider(authorizeURL, { _ in }) as! WebViewUserAgent
expect(userAgent.viewController.modalPresentationStyle) == .formSheet
}

it("should set the redirectURL correctly when using redirect_uri") {
let provider = WebAuthentication.webViewProvider()
let userAgent = provider(authorizeURL, { _ in }) as! WebViewUserAgent
expect(userAgent.redirectURL).to(equal(redirectURL))
}

it("should set the redirectURL correctly when using returnTo") {
let provider = WebAuthentication.webViewProvider()
let userAgent = provider(logoutURL, { _ in }) as! WebViewUserAgent
expect(userAgent.redirectURL).to(equal(redirectURL))
}
}

describe("initialization") {
Expand Down

0 comments on commit bddf7a5

Please sign in to comment.