Add camera QR pairing, Bonjour discovery and pinned address recovery
This commit is contained in:
@@ -45,6 +45,24 @@ final class ProtocolTests: XCTestCase {
|
||||
XCTAssertFalse(Invitation.validCode("12345678"))
|
||||
}
|
||||
|
||||
func testWindowsInvitationTimestampAndMalformedJSON() throws {
|
||||
// System.Text.Json emits up to seven fractional digits and a numeric UTC offset.
|
||||
let json = """
|
||||
{"version":1,"endpoint":"https://192.168.1.23:8765","certificateSha256":"\(fingerprint)","code":"01234567","expiresAt":"2026-09-12T15:30:00.1234567+03:00"}
|
||||
"""
|
||||
func payload(_ json: String) -> String {
|
||||
"musicbridge://pair?data=" + Data(json.utf8).base64EncodedString()
|
||||
.replacingOccurrences(of: "+", with: "-").replacingOccurrences(of: "/", with: "_").replacingOccurrences(of: "=", with: "")
|
||||
}
|
||||
let before = try XCTUnwrap(ISO8601DateFormatter().date(from: "2026-09-12T12:29:00Z"))
|
||||
XCTAssertEqual(try Invitation.parse(payload(json), now: before).code, "01234567")
|
||||
XCTAssertThrowsError(try Invitation.parse(payload(json), now: before.addingTimeInterval(120)))
|
||||
XCTAssertThrowsError(try Invitation.parse(payload("{}"), now: before)) { error in
|
||||
XCTAssertTrue(error is BridgeError)
|
||||
}
|
||||
XCTAssertThrowsError(try Invitation.parse("https://example.com"))
|
||||
}
|
||||
|
||||
func testWindowsSnapshotAndTimeline() throws {
|
||||
let url = try XCTUnwrap(Bundle(for: Self.self).url(forResource: "state-v1", withExtension: "json"))
|
||||
let state = try JSONDecoder().decode(MediaState.self, from: Data(contentsOf: url))
|
||||
|
||||
Reference in New Issue
Block a user