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>
52 lines
1.7 KiB
Python
52 lines
1.7 KiB
Python
import pytest
|
|
|
|
from secrets_engine.catalog import validate_entry
|
|
from secrets_engine.decisions import Decision, require_approved, resolve_decision
|
|
from secrets_engine.errors import DecisionError
|
|
|
|
from tests.test_catalog import VALID
|
|
|
|
|
|
def _approved(model="decision"):
|
|
d = dict(VALID, approval={"model": model, "decision_ref": "x"})
|
|
return validate_entry(d)
|
|
|
|
|
|
def test_bootstrap_only_needs_no_decision():
|
|
e = validate_entry(dict(VALID, approval={"model": "bootstrap-only"}))
|
|
require_approved(e, None) # must not raise
|
|
|
|
|
|
def test_unapproved_decision_refused():
|
|
e = _approved()
|
|
d = Decision(id="d", title="t", status="pending", superseded_by=None, source="hub")
|
|
with pytest.raises(DecisionError):
|
|
require_approved(e, d)
|
|
|
|
|
|
def test_superseded_decision_refused():
|
|
e = _approved()
|
|
d = Decision(id="d", title="t", status="resolved", superseded_by="d2", source="hub")
|
|
with pytest.raises(DecisionError):
|
|
require_approved(e, d)
|
|
|
|
|
|
def test_approved_decision_passes():
|
|
e = _approved()
|
|
d = Decision(id="d", title="t", status="resolved", superseded_by=None, source="hub")
|
|
require_approved(e, d) # must not raise
|
|
|
|
|
|
def test_local_fixture_resolves(tmp_path):
|
|
(tmp_path / ".decisions").mkdir()
|
|
(tmp_path / ".decisions" / "myref.yaml").write_text(
|
|
"id: myref\ntitle: t\nstatus: resolved\nsuperseded_by: null\n"
|
|
)
|
|
d = resolve_decision(hub_url="http://127.0.0.1:1", repo_root=tmp_path, decision_ref="myref")
|
|
assert d.source == "local-fixture"
|
|
assert d.is_approved()
|
|
|
|
|
|
def test_missing_decision_raises(tmp_path):
|
|
with pytest.raises(DecisionError):
|
|
resolve_decision(hub_url="http://127.0.0.1:1", repo_root=tmp_path, decision_ref="nope")
|