p2p-swift / Tests / IrdP2PCryptoTests / InviteLinkTests.swift
57 words
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
import Foundation
import Testing
@testable import IrdP2PCrypto

@Suite struct InviteLinkTests {
    @Test func secretRidesInTheFragment() throws {
        let s = RoomSecret.random()
        let url = InviteLink.url(base: URL(string: "https://example.test/join?x=1")!, secret: s)
        #expect(url.absoluteString == "https://example.test/join?x=1#\(s.base64URL)")
        #expect(InviteLink.secret(from: url) == s)
        #expect(InviteLink.secret(from: URL(string: "myapp://join#\(s.base64URL)")!) == s)
    }

    @Test func rejectsMissingOrShortFragment() {
        #expect(InviteLink.secret(from: URL(string: "https://example.test/join")!) == nil)
        #expect(InviteLink.secret(from: URL(string: "https://example.test/join#AAAA")!) == nil)
    }
}

static mirror of HEAD · about · clone: git clone https://ird.cod-sursa.ro/p2p-swift.git