Skip to content

test(apple): cache invariant regression tests for biometric caching#163

Merged
jgowdy-godaddy merged 1 commit into
mainfrom
test/cache-invariant-regression-tests
May 21, 2026
Merged

test(apple): cache invariant regression tests for biometric caching#163
jgowdy-godaddy merged 1 commit into
mainfrom
test/cache-invariant-regression-tests

Conversation

@jgowdy-godaddy
Copy link
Copy Markdown
Contributor

Summary

  • Add 7 tests to guard the wrapping-key cache invariants that prevent biometric prompt regressions
  • 5 pure-Rust unit tests run in CI on every commit (no keychain needed)
  • 2 keychain integration tests (#[ignore]) for local validation
  • The key test migration_restore_must_not_evict_cache would have caught the PR fix(apple): handle errSecInteractionNotAllowed and change keychain protection class #158 regression — it asserts that the protection-class migration path does not evict the cache, with an explicit failure message explaining the Touch ID consequence

Context

The biometric caching regression (#162) happened because there were zero tests covering the cache behavior across the migration path. Any future change to decrypt_with_cached_key or the keychain_store/keychain_store_ffi split will now fail these tests with a clear message.

Test plan

  • cargo test --workspace — all pass (5 new tests run, 2 new #[ignore] skipped)
  • cargo clippy --workspace --all-targets -- -D warnings — clean
  • cargo fmt --all -- --check — clean

…egressions

Add 7 tests for the wrapping-key cache layer:

5 pure-Rust unit tests (run in CI, no keychain needed):
- cache_insert_then_lookup_returns_key
- cache_evict_removes_entry
- cache_lookup_with_zero_ttl_always_misses
- cache_entries_are_isolated_by_label / by_app
- keychain_store_evicts_cache
- migration_restore_must_not_evict_cache (key regression guard)

2 keychain integration tests (#[ignore], run locally):
- decrypt_with_cached_key_preserves_cache_after_migration
- keychain_store_evicts_but_keychain_store_ffi_does_not

The migration_restore_must_not_evict_cache test directly guards the
invariant broken in PR #158 — if anyone changes the migration path
in decrypt_with_cached_key to call keychain_store instead of
keychain_store_ffi, this test fails with an explicit message
explaining the biometric caching consequences.
@jgowdy-godaddy jgowdy-godaddy merged commit 3569768 into main May 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant