Cotton code
31 lines · 1.9 KB · SwiftRaw
import CottonKitimport XCTest/// RULE (19 Nov 2026): a Cotton passkey is offered only where the sheet can take it — the app is/// signed for exactly the host it signs in at (`CottonPasskeyHost`, stamped by the spec gate beside the/// `webcredentials:` entitlement) and the phone has a passcode.final class PasskeyPlatformTests: XCTestCase {    func testOffersOnlyForTheStampedHostOnAPhoneWithAPasscode() {        XCTAssertTrue(PasskeyPlatform.offers(stampedHost: "cottondb.com", server: "https://cottondb.com", passcodeSet: true))        XCTAssertTrue(PasskeyPlatform.offers(stampedHost: "Cottondb.com", server: "https://cottondb.com/", passcodeSet: true))        XCTAssertTrue(PasskeyPlatform.offers(stampedHost: "dev.example.invalid", server: "https://dev.example.invalid", passcodeSet: true))    }    func testOffersNothingWithoutAPasscode() {        XCTAssertFalse(PasskeyPlatform.offers(stampedHost: "cottondb.com", server: "https://cottondb.com", passcodeSet: false))    }    func testOffersNothingInAnAppSignedForNoHostOrAnother() {        XCTAssertFalse(PasskeyPlatform.offers(stampedHost: nil, server: "https://cottondb.com", passcodeSet: true))        XCTAssertFalse(PasskeyPlatform.offers(stampedHost: "", server: "https://cottondb.com", passcodeSet: true))        // An unexpanded setting is no host.        XCTAssertFalse(PasskeyPlatform.offers(stampedHost: "$(COTTON_SIGNIN_HOST)", server: "https://cottondb.com", passcodeSet: true))        // The live app's host is not the dev Worker's, nor the other way round.        XCTAssertFalse(PasskeyPlatform.offers(stampedHost: "cottondb.com", server: "https://dev.example.invalid", passcodeSet: true))        XCTAssertFalse(PasskeyPlatform.offers(stampedHost: "cottondb.com", server: "http://cottondb.com", passcodeSet: true))    }    func testTheKeyIsTheOneTheGateStamps() {        XCTAssertEqual(PasskeyPlatform.hostKey, "CottonPasskeyHost")    }}