| 1 | import XCTest |
| 2 | @testable import CallsKit |
| 3 | |
| 4 | final class MeetingLinkTests: XCTestCase { |
| 5 | @MainActor func testInvitationOpensInLobbyWithoutJoiningOrStartingAuthentication() { |
| 6 | let model = CallsModel(store: MemorySessionStore()) |
| 7 | model.openMeetingURL(URL(string: "oficina-calls://join?url=https%3A%2F%2Fcalls.example.com%2Fj%2Finvitation")!) |
| 8 | XCTAssertEqual(model.pendingLink, "https://calls.example.com/j/invitation") |
| 9 | XCTAssertEqual(model.server, CallsServer.defaultOrigin, "a link never changes the server") |
| 10 | XCTAssertFalse(model.joining) |
| 11 | XCTAssertFalse(model.authenticating) |
| 12 | } |
| 13 | |
| 14 | @MainActor func testRejectsUntrustedURLShapesAndDoesNotInterruptCall() { |
| 15 | let model = CallsModel(store: MemorySessionStore()) |
| 16 | for target in ["file:///j/token", "https://user:secret@calls.example.com/j/token", "https://calls.example.com/settings"] { |
| 17 | var link = URLComponents(string: "oficina-calls://join")! |
| 18 | link.queryItems = [URLQueryItem(name: "url", value: target)] |
| 19 | model.openMeetingURL(link.url!) |
| 20 | XCTAssertEqual(model.pendingLink, "") |
| 21 | XCTAssertFalse(model.error.isEmpty) |
| 22 | } |
| 23 | model.joining = true |
| 24 | model.pendingLink = "current" |
| 25 | model.openMeetingURL(URL(string: "oficina-calls://join?url=https%3A%2F%2Fcalls.example.com%2Fm%2Froom")!) |
| 26 | XCTAssertEqual(model.pendingLink, "current") |
| 27 | XCTAssertTrue(model.joining) |
| 28 | } |
| 29 | } |
| 30 | |