Make panic wipe deterministic and device-bound

This commit is contained in:
jack
2026-07-10 20:44:20 +02:00
parent 733098bb63
commit 917c477012
11 changed files with 317 additions and 69 deletions
@@ -1,10 +1,31 @@
import Foundation
import Testing
import BitFoundation
@testable import bitchat
@Suite("PreviewKeychainManager Tests")
struct PreviewKeychainManagerTests {
@Test("Install lifecycle distinguishes upgrade, reinstall, bootstrap, and unreadable keychain")
func installLifecycleDecision() {
#expect(KeychainManager.installLifecycleAction(
containerKnowsMarker: true,
markerRead: .success(Data([1]))
) == .markerPresent)
#expect(KeychainManager.installLifecycleAction(
containerKnowsMarker: false,
markerRead: .success(Data([1]))
) == .clearStaleKeys)
#expect(KeychainManager.installLifecycleAction(
containerKnowsMarker: false,
markerRead: .itemNotFound
) == .bootstrapMarker)
#expect(KeychainManager.installLifecycleAction(
containerKnowsMarker: false,
markerRead: .deviceLocked
) == .retryLater)
}
@Test("Preview keychain manager stores identity and service-scoped data in memory")
func previewKeychainManagerRoundTripsData() {
let manager = PreviewKeychainManager()