Skip to content

Commit

Permalink
chore: addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
desusai7 committed Jul 5, 2024
1 parent 2479461 commit 9acf0da
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 11 deletions.
3 changes: 1 addition & 2 deletions Auth0/MobileWebAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ extension ASUserAgent: ASWebAuthenticationPresentationContextProviding {
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
if let windowScene = UIApplication.shared()?.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
return windowScene.windows.last(where: \.isKeyWindow) ?? ASPresentationAnchor()
} else {
return ASPresentationAnchor()
}
return ASPresentationAnchor()
}
#endif

Expand Down
6 changes: 1 addition & 5 deletions Auth0Tests/CredentialsManagerSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,6 @@ class CredentialsManagerSpec: QuickSpec {

context("renewal") {

beforeEach {

}

it("should yield new credentials without refresh token rotation") {
credentials = Credentials(accessToken: AccessToken, tokenType: TokenType, idToken: IdToken, refreshToken: RefreshToken, expiresIn: Date(timeIntervalSinceNow: -ExpiresIn))
_ = credentialsManager.store(credentials: credentials)
Expand Down Expand Up @@ -1197,7 +1193,7 @@ class CredentialsManagerSpec: QuickSpec {
let key = "foo"
let value = "bar"
let credentialsManager = credentialsManager!
NetworkStub.addStub(condition: { $0.isToken(Domain) && $0.hasAtLeast(["refresh_token": RefreshToken, key: value])}, response: authResponse(accessToken: NewAccessToken, idToken: NewIdToken, refreshToken: NewRefreshToken, expiresIn: ExpiresIn))
NetworkStub.addStub(condition: { $0.isToken(Domain) && $0.hasAtLeast(["refresh_token": RefreshToken, key: value]) && $0.hasHeader(key, value: value)}, response: authResponse(accessToken: NewAccessToken, idToken: NewIdToken, refreshToken: NewRefreshToken, expiresIn: ExpiresIn))
credentials = Credentials(accessToken: AccessToken, tokenType: TokenType, idToken: IdToken, refreshToken: RefreshToken, expiresIn: Date(timeIntervalSinceNow: -ExpiresIn))
_ = credentialsManager.store(credentials: credentials)
waitUntil(timeout: Timeout) { done in
Expand Down
4 changes: 2 additions & 2 deletions Auth0Tests/IDTokenValidatorBaseSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class IDTokenValidatorBaseSpec: QuickSpec {
static let organization = "abc1234"

// Can't override the initWithInvocation: initializer, because NSInvocation is not available in Swift
static var authentication = Auth0.authentication(clientId: clientId, domain: domain)
static var validatorContext = IDTokenValidatorContext(issuer: URL.httpsURL(from: domain).absoluteString,
static let authentication = Auth0.authentication(clientId: clientId, domain: domain)
static let validatorContext = IDTokenValidatorContext(issuer: URL.httpsURL(from: domain).absoluteString,
audience: clientId,
jwksRequest: authentication.jwks(),
leeway: leeway,
Expand Down
2 changes: 1 addition & 1 deletion Auth0Tests/NetworkStub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ typealias RequestCondition = (URLRequest) -> Bool
typealias RequestResponse = (URLRequest) -> (Data?, URLResponse?, Error?)

struct NetworkStub {
static var stubs: [(condition: RequestCondition, response: RequestResponse)] = []
static private(set) var stubs: [(condition: RequestCondition, response: RequestResponse)] = []

static func addStub(condition: @escaping RequestCondition, response: @escaping RequestResponse) {
stubs.append((condition, response))
Expand Down
2 changes: 1 addition & 1 deletion Auth0Tests/Responses.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func catchAllResponse() -> RequestResponse {
func apiSuccessResponse(json: [AnyHashable: Any] = [:]) -> RequestResponse {
return { request in
let data = try! JSONSerialization.data(withJSONObject: json, options: [])
let response = HTTPURLResponse(url: request.url!, statusCode: APISuccessStatusCode, httpVersion: nil, headerFields: APIResponseHeaders)
let response = HTTPURLResponse(url: request.url!, statusCode: APISuccessStatusCode, httpVersion: nil, headerFields: APIResponseHeaders)!
return (data, response, nil)
}
}
Expand Down

0 comments on commit 9acf0da

Please sign in to comment.