@@ -568,6 +568,7 @@ mod tests {
568568 // tests; here we only verify the skip path.
569569 }
570570
571+ #[ ignore = "requires real OS keychain (run locally)" ]
571572 #[ test]
572573 fn mutate_blob_does_not_advance_cache_on_write_failure ( ) {
573574 // Copy-on-write safety: if `write_blob_raw` fails (denied prompt,
@@ -576,40 +577,46 @@ mod tests {
576577 // must NOT be skipped as a no-op — the equality check must compare
577578 // against the durable cache, not an unpersisted candidate.
578579 //
579- // On unsigned CI builds the keychain is unreachable, so any `store()`
580- // for a key not already in the warm cache will call `write_blob_raw`
581- // and receive an error. We verify that after the error:
580+ // This is a real-keychain integration test. Run locally with:
581+ // cargo test -p buzz-desktop -- --ignored mutate_blob_does_not_advance
582+ //
583+ // On a machine with a reachable keychain the `store()` call succeeds
584+ // (result.is_ok()) and the write-failure branch is skipped — the test
585+ // still passes. On a machine where the write is denied (e.g., user
586+ // clicks Deny in the macOS prompt) result.is_err() and the assertions
587+ // below verify the cache invariant. We verify that after an error:
582588 // 1. The cache is not advanced (the previously cached key is intact).
583589 // 2. The failed key is not present (the dirty candidate was discarded).
584590 let mut map = HashMap :: new ( ) ;
585591 map. insert ( "existing" . to_string ( ) , "durable_val" . to_string ( ) ) ;
586592 let store = SecretStore :: with_cache ( "buzz-test-cow-write-fail" , Some ( map) ) ;
587593
588- // Attempt to add a new key — on unsigned CI this will try write_blob_raw
589- // and fail; with copy-on-write the cache must remain at {existing}.
594+ // Attempt to add a new key — this calls write_blob_raw against the
595+ // real keychain; with copy-on-write the cache must remain at {existing}
596+ // if the write fails.
590597 let result = store. store ( "new_key" , "new_val" ) ;
591598
592599 if result. is_err ( ) {
593- // Write failed (expected on unsigned CI ): confirm cache was not
594- // advanced — the existing key is still intact and the new key
595- // was never committed to the in-memory state.
600+ // Write failed (e.g., user denied the keychain prompt ): confirm
601+ // cache was not advanced — the existing key is still intact and
602+ // the new key was never committed to the in-memory state.
596603 assert_eq ! (
597604 store. load( "existing" ) . unwrap( ) ,
598605 Some ( "durable_val" . to_string( ) ) ,
599606 "cache must remain at last durable state after write failure"
600607 ) ;
601608 // load("new_key") goes through the unchanged cache (no entry),
602- // then attempts migrate_legacy_key which also fails on unsigned CI,
603- // returning either Ok(None) or Err — either is correct since the
604- // key was never durably stored.
609+ // then attempts migrate_legacy_key which also fails on a denied
610+ // keychain, returning either Ok(None) or Err — either is correct
611+ // since the key was never durably stored.
605612 let after = store. load ( "new_key" ) ;
606613 assert ! (
607614 matches!( after, Ok ( None ) | Err ( _) ) ,
608615 "a key whose write failed must not be visible via load: {after:?}"
609616 ) ;
610617 }
611- // If result.is_ok() the test ran on a machine with a real keychain and
612- // the write succeeded — no assertion needed for the failure path .
618+ // If result.is_ok() the write succeeded — the cache-integrity invariant
619+ // does not apply to the success path; no assertion needed here .
613620 }
614621
615622 #[ test]
0 commit comments