feat(mvp): working secrets-engine CLI for the whynot-design npm publish lane
Implements SECRETS-WP-0002 end to end as a uv-managed Python package: - catalog: non-secret lane registry + strict validator (build/test/prod) - stage roles + OpenBao ACL policies; guards refuse wildcards, sys/, identity/, admin names, and cross-stage paths before any backend call - plan/apply: dry-run-first, idempotent policy + approle apply, decision-gated - decisions: State Hub lookup with local-fixture fallback; non-secret evidence to JSONL + hub progress, scrubbed of any value - provision/verify: mode-0600 file import + generated test values; positive/ negative checks that never print the value - exec delivery: `exec --catalog ... -- npm publish` injects the token via a temp .npmrc for the child only, cleaned up on exit/failure/interrupt - ops-warden routing contract + hardening backlog docs - 34 tests incl. live OpenBao integration; scripts/demo-e2e.sh runs the full chain against a throwaway bao dev server Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
58c24cff53
commit
a852d3f1ff
47 changed files with 3743 additions and 122 deletions
77
tests/test_catalog.py
Normal file
77
tests/test_catalog.py
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
import copy
|
||||
|
||||
import pytest
|
||||
|
||||
from secrets_engine.catalog import validate_entry, load_catalog
|
||||
from secrets_engine.config import repo_root
|
||||
from secrets_engine.errors import CatalogError
|
||||
|
||||
VALID = {
|
||||
"id": "test-lane",
|
||||
"owner": "team",
|
||||
"stage": "test",
|
||||
"mount": "secret",
|
||||
"path": "test/team/thing",
|
||||
"fields": ["api_token"],
|
||||
"consumers": [{"name": "c", "auth": "approle", "claim": "role:c"}],
|
||||
"delivery_modes": ["exec-env"],
|
||||
"approval": {"model": "bootstrap-only"},
|
||||
"verification": {"positive": "x", "negative": "y"},
|
||||
"rotation": {"ttl": "1h"},
|
||||
"deactivation": {"expectation": "delete"},
|
||||
"audit": {"evidence": "non-secret"},
|
||||
}
|
||||
|
||||
|
||||
def test_valid_entry_parses():
|
||||
e = validate_entry(VALID)
|
||||
assert e.id == "test-lane"
|
||||
assert e.policy_name == "se-test-test-lane"
|
||||
assert not e.approval_required()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("field", ["stage", "mount", "path", "fields", "approval", "delivery_modes"])
|
||||
def test_missing_required_field_rejected(field):
|
||||
data = copy.deepcopy(VALID)
|
||||
data.pop(field)
|
||||
with pytest.raises(CatalogError):
|
||||
validate_entry(data)
|
||||
|
||||
|
||||
def test_bad_stage_rejected():
|
||||
data = copy.deepcopy(VALID)
|
||||
data["stage"] = "staging"
|
||||
with pytest.raises(CatalogError):
|
||||
validate_entry(data)
|
||||
|
||||
|
||||
def test_unknown_delivery_mode_rejected():
|
||||
data = copy.deepcopy(VALID)
|
||||
data["delivery_modes"] = ["telepathy"]
|
||||
with pytest.raises(CatalogError):
|
||||
validate_entry(data)
|
||||
|
||||
|
||||
def test_wildcard_path_rejected():
|
||||
data = copy.deepcopy(VALID)
|
||||
data["path"] = "test/*"
|
||||
with pytest.raises(CatalogError):
|
||||
validate_entry(data)
|
||||
|
||||
|
||||
def test_inline_secret_value_rejected():
|
||||
data = copy.deepcopy(VALID)
|
||||
data["token"] = "npm_realvalue"
|
||||
with pytest.raises(CatalogError):
|
||||
validate_entry(data)
|
||||
|
||||
|
||||
def test_repo_catalog_loads_and_has_pilot():
|
||||
entries = load_catalog(repo_root() / "catalog")
|
||||
assert "whynot-design-npm-publish" in entries
|
||||
pilot = entries["whynot-design-npm-publish"]
|
||||
assert pilot.stage == "prod"
|
||||
assert pilot.approval_required()
|
||||
# build/test/prod stage separation is representable
|
||||
stages = {e.stage for e in entries.values()}
|
||||
assert {"build", "prod"} <= stages
|
||||
Loading…
Add table
Add a link
Reference in a new issue