import json from secrets_engine.evidence import EvidenceWriter, _scrub from secrets_engine.redact import looks_secret, redact_text def test_redact_known_token_shapes(): assert "npm_" not in redact_text("token=npm_abcdEFGH12345678abcd") assert "REDACTED" in redact_text("token=npm_abcdEFGH12345678abcd") assert "ghp_" not in redact_text("ghp_0123456789abcdef0123") def test_redact_extra_literal(): out = redact_text("the value is hunter2hunter2", extra=["hunter2hunter2"]) assert "hunter2" not in out def test_looks_secret(): assert looks_secret("npm_token") assert looks_secret("API_KEY") assert not looks_secret("path") def test_scrub_drops_secret_keys_and_redacts(): scrubbed = _scrub({"token": "npm_realvalue123456789", "path": "a/b", "note": "ghp_0123456789abcdef0123"}) assert scrubbed["token"].startswith("