Skip to content

test(matrix): W3 vault-block integration suite (move exempt→mapped)#252

Merged
mastermanas805 merged 1 commit into
masterfrom
test/vault-block-integration-2026-06-05
Jun 4, 2026
Merged

test(matrix): W3 vault-block integration suite (move exempt→mapped)#252
mastermanas805 merged 1 commit into
masterfrom
test/vault-block-integration-2026-06-05

Conversation

@mastermanas805

Copy link
Copy Markdown
Member

What

Closes the vault routes the api done-bar guard (internal/router/route_donebar_guard_test.go) carried as either the shallow TestMerged_Vault_RequiresAuth requires-auth probe (GET /vault/:env, GET /vault/:env/:key, PUT /vault/:env/:key) or as routeCoverageExemptions TODO-rows with no mapped test (POST /vault/:env/:key/rotate, DELETE /vault/:env/:key, POST /vault/copy).

A new DB-backed handler-integration suite drives every vault route through the production RequireAuth + PopulateTeamRole + RequireEnvAccess(VaultWrite) chain (vaultBlockApp mirrors router.New, real JWTs, live SetRoleLookupDB/SetEnvPolicyDB) against a real Postgres (testhelpers.SetupTestDB).

Coverage

Route Test
GET /api/v1/vault/:env TestVaultBlock_ListKeys
GET /api/v1/vault/:env/:key TestVaultBlock_GetSecret
PUT /api/v1/vault/:env/:key TestVaultBlock_PutSecret
POST /api/v1/vault/:env/:key/rotate TestVaultBlock_RotateSecret
DELETE /api/v1/vault/:env/:key TestVaultBlock_DeleteSecret
POST /api/v1/vault/copy TestVaultBlock_CopySecrets

Asserts: happy path + versioned writes; encrypt/decrypt-at-rest (ciphertext at rest never contains plaintext, GET decrypts to original, list never returns values); authz (free=403 not-available, hobby non-prod env=403, env_policy locks prod vault_write to owner → developer 403 env_policy_denied, copy on non-multi-env tier=402, missing bearer=401); cross-team isolation (team B read/delete of team A's secret → 404 never 403, secret survives); rotate semantics (new version + distinct rotate audit + Idempotency-Key replay = no dup version); copy semantics (dry_run persists nothing, skip-by-default vs overwrite, missing-source, encrypted bytes preserved); input validation.

Guard

Six vault rows move routeCoverageExemptions/shallow-probe → routeTestMap pointing at TestVaultBlock_*. Both done-bar guards stay GREEN (TestDoneBar_EveryRouteCovered + TestDoneBar_TestMapPointsAtRealTests).

Scope

Test-only — no handler-source edits. make gate green locally (only the two documented pre-existing local-env flakes — TestLinkGitHubID UUID-order in internal/models, TestQueue_CredIssueError_FallsBackToLegacyOpen NATS 503 in internal/handlers — both reproduce identically on clean origin/master; CI authoritative).

🤖 Generated with Claude Code

Closes the vault routes the done-bar guard
(internal/router/route_donebar_guard_test.go) carried as either the
shallow TestMerged_Vault_RequiresAuth requires-auth probe (GET list, GET
key, PUT key) or as routeCoverageExemptions TODO-rows with no mapped test
(POST rotate, DELETE key, POST copy).

New DB-backed handler-integration suite
(internal/handlers/vault_block_routes_test.go +
vault_block_helpers_test.go) drives every vault route through the
production RequireAuth + PopulateTeamRole + RequireEnvAccess(VaultWrite)
chain (vaultBlockApp mirrors router.New) against a real Postgres:

  - happy path: write/read/list/rotate/delete/copy + versioned writes
  - encrypt/decrypt-at-rest: ciphertext at rest never contains plaintext;
    GET decrypts to the original; list path never returns values
  - authz: free=403 not-available, hobby non-prod env=403, env_policy
    locks prod vault_write to owner → developer 403 env_policy_denied,
    copy on non-multi-env tier=402, missing bearer=401
  - cross-team isolation: team B read/delete of team A's secret → 404
    (never 403), and team A's secret survives B's delete attempt
  - rotate semantics: new version + distinct 'rotate' audit action +
    Idempotency-Key replay does not create a duplicate version
  - copy semantics: dry_run persists nothing, skip-by-default vs
    overwrite, missing-source reporting, encrypted bytes preserved
  - input validation: invalid key/env/version, from==to, missing from

Guard: six vault rows move routeCoverageExemptions/shallow-probe →
routeTestMap pointing at TestVaultBlock_*. Both done-bar guards stay
green (TestDoneBar_EveryRouteCovered + TestDoneBar_TestMapPointsAtRealTests).

No handler-source edits — test-only PR.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mastermanas805 mastermanas805 enabled auto-merge (squash) June 4, 2026 23:10
@mastermanas805 mastermanas805 merged commit bdc408b into master Jun 4, 2026
18 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