Skip to content

Commit 7488598

Browse files
committed
Fix the ephemeralSession BrowserSignin convenience property
1 parent 5803fb1 commit 7488598

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

Sources/BrowserSignin/BrowserSignin.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ public final class BrowserSignin {
113113
options.contains(.ephemeralSession)
114114
}
115115
set {
116-
options.insert(.ephemeralSession)
116+
if newValue {
117+
options.insert(.ephemeralSession)
118+
} else {
119+
options.remove(.ephemeralSession)
120+
}
117121
}
118122
}
119123
#endif

Tests/BrowserSigninTests/BrowserSigninInitializerTests.swift

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ class BrowserSigninInitializerTests: XCTestCase {
2121
private let redirectUri = URL(string: "com.example:/callback")!
2222
private let logoutRedirectUri = URL(string: "com.example:/logout")!
2323

24+
override func setUp() async throws {
25+
await MainActor.run {
26+
BrowserSignin.providerFactory = BrowserSigninProviderFactoryMock.self
27+
}
28+
}
29+
30+
override func tearDown() async throws {
31+
await BrowserSignin.resetToDefault()
32+
}
33+
2434
func testInitializer() async throws {
2535
let auth = await BrowserSignin(
2636
issuerURL: issuer,
@@ -38,4 +48,27 @@ class BrowserSigninInitializerTests: XCTestCase {
3848
XCTAssertEqual(auth.signInFlow.additionalParameters?.stringComponents, ["foo": "bar"])
3949
XCTAssertEqual(auth.signOutFlow?.additionalParameters?.stringComponents, ["foo": "bar"])
4050
}
51+
52+
@MainActor
53+
func testOptions() async throws {
54+
let auth = BrowserSignin(
55+
issuerURL: issuer,
56+
clientId: "client_id",
57+
scope: "openid profile",
58+
redirectUri: redirectUri)
59+
60+
XCTAssertEqual(auth.options, [])
61+
62+
auth.ephemeralSession = true
63+
XCTAssertEqual(auth.options, [.ephemeralSession])
64+
XCTAssertTrue(auth.ephemeralSession)
65+
66+
auth.ephemeralSession = false
67+
XCTAssertEqual(auth.options, [])
68+
XCTAssertFalse(auth.ephemeralSession)
69+
70+
auth.options = [.ephemeralSession]
71+
XCTAssertEqual(auth.options, [.ephemeralSession])
72+
XCTAssertTrue(auth.ephemeralSession)
73+
}
4174
}

0 commit comments

Comments
 (0)