// The phone persists a NO, never a yes — and it does not persist the NO EITHER. // // There is no approved flag and there must not be one: the SERVER's row says // who is in, and a phone that remembered "yes" would be a second, staler // opinion about an approval only the server can grant. // // The port originally kept the terminal refusal in `UserDefaults`, so a relaunch // painted the sentence rather than trusting that the leave which followed the // refusal succeeded. **That half moved below the boundary when 4b's Rust landed:** // the transport that was refused writes `client/refusal.json` and `read.boot` // hands the note back as `refusal`. Two copies of one fact, one on each side of // the FFI, could disagree the moment a leave cleared one of them — and the one // the screen read was the stale one. So the key is retired, and this file is // what stops it coming back quietly. import XCTest @testable import CottonKit final class NoStandingTests: XCTestCase { private func freshDefaults(_ name: String = #function) -> UserDefaults { let suite = "cotton.tests.\(name).\(UUID().uuidString)" let defaults = UserDefaults(suiteName: suite)! defaults.removePersistentDomain(forName: suite) return defaults } func testEveryDeclaredKeyIsAPreferenceAndNotAClaim() { let keys = Set(StandingKey.allCases.map(\.rawValue)) for key in keys { XCTAssertFalse( key.lowercased().contains("approv"), "\(key) reads as a claim about an approval, which is the server's to make" ) XCTAssertFalse(key.lowercased().contains("token")) XCTAssertFalse(key.lowercased().contains("session")) } } func testTheServerAddressIsNotKeptHere() { // It lives in Rust's `client/connection.json`; Swift holds no copy. // One writer, one reader, one file. for key in StandingKey.allCases.map(\.rawValue) { XCTAssertFalse(key.contains("server")) XCTAssertFalse(key.contains("workspace")) XCTAssertFalse(key.contains("baseUrl")) } } func testNothingIsWrittenToTheSuiteByDeclaringIt() { // The suite exists for the notification switches and for whatever a // later step adds with its own line there. Reading it must not CREATE // anything. let defaults = freshDefaults() XCTAssertNil(defaults.object(forKey: StandingKey.notificationPrefs.rawValue)) XCTAssertNil(defaults.object(forKey: RETIRED_REFUSAL_KEY)) } // The GROUP derivation moved out of this file. // // There are now two answers — the phone's, trimmed off the bundle id, and // the Mac's one team-prefixed constant — and a table of both, for all five // bundle ids on either system, is `AppGroupTests` in this same target. One // guard rather than two half-tables: this file's own subject is which KEYS // may be written, not which container they land in. }