Skip to content

Commit

Permalink
Update deviceIdentifier tests on non-macOS targets
Browse files Browse the repository at this point in the history
  • Loading branch information
mikenachbaur-okta committed Feb 29, 2024
1 parent 4854214 commit b980b54
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Tests/OktaIdxTests/DeviceIdentifierTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
import XCTest
@testable import OktaIdx

#if SWIFT_PACKAGE
@testable import TestCommon
#endif

#if canImport(UIKit)
import UIKit
#endif
Expand All @@ -34,7 +38,15 @@ final class DeviceIdentifierTests: XCTestCase {

#if canImport(UIKit) && (os(iOS) || os(macOS) || os(tvOS) || canImport(WatchKit))
func testDeviceIdentifier() throws {
let identifier = try XCTUnwrap(InteractionCodeFlow.deviceIdentifier)
let urlSession = URLSessionMock()
let issuer = try XCTUnwrap(URL(string: "https://example.com/oauth2/default"))
let redirectUri = try XCTUnwrap(URL(string: "redirect:/uri"))
let client = OAuth2Client(baseURL: issuer,
clientId: "clientId",
scopes: "openid profile",
session: urlSession)
let flow = InteractionCodeFlow(redirectUri: redirectUri, client: client)
let identifier = try XCTUnwrap(flow.deviceIdentifierString)

// Device Token string _must_ be 32 characters or less.
XCTAssertLessThanOrEqual(identifier.count, 32)
Expand Down

0 comments on commit b980b54

Please sign in to comment.