Skip to content

test(hub-vault): add HubVaultService unit coverage (14 tests)#187

Merged
yishuiliunian merged 1 commit into
mainfrom
test/hub-vault-coverage
May 27, 2026
Merged

test(hub-vault): add HubVaultService unit coverage (14 tests)#187
yishuiliunian merged 1 commit into
mainfrom
test/hub-vault-coverage

Conversation

@yishuiliunian
Copy link
Copy Markdown
Contributor

Summary

loopal-hub-vault had no tests/ directory — HubVaultService was only exercised transitively through 4 tests in loopal-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).

Test Covers
get_returns_secret_for_existing_name basic get round-trip
get_returns_secret_not_found_for_missing_name typed SecretNotFound surface
list_names_returns_all_keys_sorted list_names contract
vault_for_missing_cwd_returns_vault_not_found empty vaults/ dir → typed VaultNotFound
vault_for_nonexistent_path_returns_vault_not_found canonicalize failure → typed VaultNotFound
vault_for_caches_vault_handle_per_cwd 5 sequential gets via cache
open_default_vault_prefers_default_when_multiple_present naming priority
open_default_vault_falls_back_to_alphabetical_first no "default" → alphabetical
expand_author_substitutes_double_brace_template {{secret:NAME}}
expand_wire_substitutes_secret_ref_template <secret_ref:NAME>
expand_author_propagates_missing_secret_error error propagation through expand
expand_author_no_placeholders_passes_through_verbatim no-op template
two_cwds_get_independent_vault_instances cache keyed by canonical cwd
with_noop_audit_constructor_compiles_and_runs env-tolerant smoke (no ~/.ssh/)

Approach

Tests use the public age crate fixtures (alice's ed25519 keypair) to construct real on-disk AgeVault stores under tempfile::tempdir(), then drive HubVaultService directly. No IPC, no Hub setup, no mocks — pure method-level coverage.

Test plan

  • CI passes (bazel build / test / clippy / rustfmt)
  • 14 new tests pass locally

Closes the last identified audit gap from the systematic e2e review.

`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.
@yishuiliunian yishuiliunian merged commit 7a5cbff into main May 27, 2026
4 checks passed
@yishuiliunian yishuiliunian deleted the test/hub-vault-coverage branch May 27, 2026 02:19
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