test: cover high-risk crypto, restore, and CLI paths - #53
Merged
Merged
Conversation
Fill the genuine test gaps in the highest-risk crate (driven-crypto): - keystore.rs had ZERO tests (the only crypto module without any). Extract the keyring-result -> domain mapping into pure free fns (map_load_secret, map_delete_result) - matching the deliberate, CI-safe pattern the sibling driven-drive::token_store already uses (the keyring 4.1.2 mock store is not a declared dependency and a real round-trip is flaky on headless CI) - and unit-test them: NoEntry -> NotFound, wrong-length secret -> MalformedKey(n) (empty / short / long), a 32-byte secret -> the exact MasterKey, any other backend error -> Backend, and idempotent delete (Ok / NoEntry both Ok). - Add the end-to-end disaster-recovery chain to lib.rs suite_tests: master key -> wrap a per-source key -> persist the wrapped blob + write down the BIP39 phrase -> encrypt a file + path components -> drop the suite (model a wiped keychain) -> recover master from the phrase -> unwrap the SAME source key from the persisted blob -> decrypt the old ciphertext and filenames. This ties together recovery + key-wrapping + content STREAM + filename encryption (each only unit-tested in isolation before). Also assert a different (valid) phrase fails to unwrap the source key (DecryptFailed). No production behavior change - the keystore methods delegate to the new pure fns with identical semantics. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MZQh3ZfwtZsM6c5qnTuWZP
Contributor
Coverage
Gate: passed - no coverage regression (epsilon 0.1 pp). |
pmaxhogan
marked this pull request as ready for review
June 27, 2026 01:47
pmaxhogan
enabled auto-merge (squash)
June 27, 2026 02:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Targeted high-risk test coverage (issue #40 scope: HIGH-RISK gaps + low-hanging
fruit, not a whole-codebase sweep).
I first mapped existing coverage. Contrary to the stale Explore notes,
driven-cryptocontent/key/filename/recovery,telemetry.rs, thesettings/accounts/restore command layer, and the CLI (
main.rs,inspect.rs,tests/cli.rs) are ALL already thoroughly unit-tested. To avoid padding withduplicate asserts, I added tests only where there was a genuine, verified gap -
both in the highest-risk crate,
driven-crypto:keystore.rshad zero tests - the only crypto module with none. The OSkeychain is not cleanly testable in-process (the keyring 4.1.2 mock store is
not a declared dependency and a real round-trip is flaky on headless CI),
which is exactly why the sibling
driven-drive::token_storeextracts itskeyring-result -> domain mapping into pure free fns and tests those. I
mirrored that established, CI-safe pattern: extracted
map_load_secret/map_delete_resultand unit-tested them -NoEntry->NotFound, anon-32-byte secret ->
MalformedKey(n)(empty / short / long), a valid32-byte secret -> the exact
MasterKey, any other backend error ->Backend, and idempotent delete. No production behavior change: the methodsdelegate to the new pure fns with identical semantics.
End-to-end disaster-recovery chain (
lib.rssuite_tests): master key-> wrap a per-source key -> persist the wrapped blob + the BIP39 phrase ->
encrypt a file + path components -> drop the suite (model a wiped keychain)
-> recover the master key from the phrase -> unwrap the SAME source key from
the persisted blob -> decrypt the old ciphertext and filenames. This ties
together recovery + key-wrapping + content STREAM + filename encryption,
each of which was only unit-tested in isolation. A companion test asserts a
different (valid) phrase fails to unwrap the source key (
DecryptFailed).Note on the title: the mandated PR title references restore/CLI paths, but
after auditing them I found both already well covered, so the net new tests
landed in crypto (the genuinely highest-risk, partially-untested surface).
Testing
All required Rust gates run from the worktree root with
CARGO_TARGET_DIRpointed at the warm shared target:cargo fmt --all -- --check- pass (exit 0)cargo build --workspace --all-targets- pass (exit 0)cargo clippy --workspace --all-targets -- -D warnings- pass (exit 0)cargo test --workspace- pass (28test result: oksections, 0 failed);driven-cryptonow 41 passing tests (8 new). No#[ignore], no weakenedtests.
No UI files were touched, so the UI gate set was not required.
Closes #40
🤖 Generated with Claude Code
https://claude.ai/code/session_01MZQh3ZfwtZsM6c5qnTuWZP