test(hub-vault): add HubVaultService unit coverage (14 tests)#187
Merged
Conversation
`loopal-hub-vault` had no tests/ dir — HubVaultService was only exercised
transitively through `e2e_real_vault_test` and `e2e_secret_access_boundary_test`
in `loopal-agent-hub` (4 tests total). Direct method-level coverage of the
crate's cache semantics, fallback-naming policy, and template-expansion paths
was missing.
New target `//crates/loopal-hub-vault:loopal-hub-vault_test` (14 tests):
- `get_returns_secret_for_existing_name`
- `get_returns_secret_not_found_for_missing_name`
- `list_names_returns_all_keys_sorted`
- `vault_for_missing_cwd_returns_vault_not_found` (empty vaults/ dir)
- `vault_for_nonexistent_path_returns_vault_not_found` (canonicalize fails)
- `vault_for_caches_vault_handle_per_cwd` (5 sequential gets via cache)
- `open_default_vault_prefers_default_when_multiple_present`
- `open_default_vault_falls_back_to_alphabetical_first` (no "default" vault)
- `expand_author_substitutes_double_brace_template` ({{secret:NAME}})
- `expand_wire_substitutes_secret_ref_template` (<secret_ref:NAME>)
- `expand_author_propagates_missing_secret_error`
- `expand_author_no_placeholders_passes_through_verbatim`
- `two_cwds_get_independent_vault_instances` (cache keyed by canonical cwd)
- `with_noop_audit_constructor_compiles_and_runs` (env-tolerant smoke)
The tests use public age fixtures (alice's ed25519 keypair) to construct
real on-disk AgeVault stores under tempdirs, then drive HubVaultService
directly. No IPC, no Hub setup — pure method-level coverage.
Closes the last identified audit gap from the systematic e2e review.
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
loopal-hub-vaulthad notests/directory —HubVaultServicewas only exercised transitively through 4 tests inloopal-agent-hub. This PR adds direct method-level coverage of the crate's cache semantics, fallback-naming policy, error paths, and template-expansion methods.New target
//crates/loopal-hub-vault:loopal-hub-vault_test(14 tests).get_returns_secret_for_existing_nameget_returns_secret_not_found_for_missing_namelist_names_returns_all_keys_sortedvault_for_missing_cwd_returns_vault_not_foundvault_for_nonexistent_path_returns_vault_not_foundvault_for_caches_vault_handle_per_cwdopen_default_vault_prefers_default_when_multiple_presentopen_default_vault_falls_back_to_alphabetical_firstexpand_author_substitutes_double_brace_template{{secret:NAME}}expand_wire_substitutes_secret_ref_template<secret_ref:NAME>expand_author_propagates_missing_secret_errorexpand_author_no_placeholders_passes_through_verbatimtwo_cwds_get_independent_vault_instanceswith_noop_audit_constructor_compiles_and_runs~/.ssh/)Approach
Tests use the public age crate fixtures (alice's ed25519 keypair) to construct real on-disk AgeVault stores under
tempfile::tempdir(), then driveHubVaultServicedirectly. No IPC, no Hub setup, no mocks — pure method-level coverage.Test plan
bazel build / test / clippy / rustfmt)Closes the last identified audit gap from the systematic e2e review.