import Foundation import WireProtocol import HostRegistry /// On macOS `Foundation.Host` (NSHost) shadows the package type in test /// files that import Foundation — pin resolution for the whole test target. typealias Host = HostRegistry.Host /// Shared fixtures for HostRegistryTests. Pure helpers only — no state. enum Fixtures { /// Builds a valid Host; traps loudly if the fixture URL is malformed /// (a broken fixture must fail the suite, not silently skip assertions). static func makeHost( name: String = "mac-studio", urlString: String = "http://192.168.1.5:3000", id: UUID = UUID() ) -> Host { guard let url = URL(string: urlString), let endpoint = HostEndpoint(baseURL: url) else { fatalError("test fixture URL invalid: \(urlString)") } return Host(id: id, name: name, endpoint: endpoint) } /// Unique UserDefaults suite name per test — isolates parallel tests. static func makeSuiteName() -> String { "HostRegistryTests." + UUID().uuidString } // MARK: - Access-token fixtures (coordination doc §1.1) /// 22 chars exercising EVERY class of the frozen charset /// `[A-Za-z0-9._~+/=-]` (upper/lower/digit/`.`/`_`/`~`/`+`/`/`/`=`/`-`), /// comfortably above the 16-char minimum. Test-only value — not a secret. static let validTokenString = "A9z._~+/=-Abcdef012345" /// A second, distinct valid token (for "replaced/other host" assertions). static let otherValidTokenString = "Zy8-=/+~_.9876543210fedcba" /// Builds a valid token; traps loudly if a fixture string is malformed /// (a broken fixture must fail the suite, not silently skip assertions). static func makeToken(_ raw: String = Fixtures.validTokenString) -> AccessToken { guard let token = AccessToken(rawValue: raw) else { fatalError("test fixture token invalid: length \(raw.count)") } return token } /// A repeated-character token of an exact length (length-boundary tests). static func tokenString(length: Int) -> String { String(repeating: "a", count: length) } }