|
Option C oc_diagnostics
|
Variables | |
| _REPO_ROOT = Path(__file__).resolve().parents[1] | |
Purpose
-------
OI-506 / FS-506 — regression coverage for the built-in secret/URL/token
scrubbers added to ``_apply_redaction``. These run unconditionally when
``REDACT_SECRETS`` is True (the default) inside production mode.
The three built-in regexes:
1. ``_GIT_URL_RE`` — strips ``user:token@`` from http(s) URLs.
2. ``_TOKEN_PREFIXES_RE`` — redacts common opaque-prefix tokens
(GitHub PATs, Slack bot tokens, OpenAI keys, JWTs).
3. ``_KV_SECRET_RE`` — redacts ``secret=value`` / ``secret: value``
style pairs for a fixed allowlist of key names.
The tests restore ``PROD_MODE`` and ``REDACT_SECRETS`` in ``finally`` so
they never leak state into neighbouring tests.
Diagnostics
-----------
Domain: TEST
Levels:
L2 — test lifecycle
Contracts
---------
- Built-ins must scrub even when ``REDACTION_PATTERNS`` is empty.
- The ``REDACT_SECRETS=False`` toggle must bypass all three built-ins.
- Dev mode (``PROD_MODE=False``) must never redact.
|
protected |
Flip PROD_MODE on and return the restore callable.
Definition at line 49 of file test_redaction.py.
| test_redaction.test_dev_mode_still_skips_all_redaction | ( | ) |
OI-506: PROD_MODE=False short-circuits the full redaction stack.
Definition at line 153 of file test_redaction.py.
| test_redaction.test_git_url_credentials_stripped | ( | ) |
OI-506: ``https://user:token@host/path`` → ``https://***@host/path``.
Definition at line 63 of file test_redaction.py.
| test_redaction.test_github_pat_prefix_redacted_in_bare_text | ( | ) |
OI-506: ``ghp_…`` tokens outside URL context are still redacted.
Definition at line 77 of file test_redaction.py.
| test_redaction.test_kv_api_key_variants_all_redacted | ( | ) |
OI-506: ``api_key``, ``api-key``, and ``apikey`` all match the KV regex.
Definition at line 117 of file test_redaction.py.
| test_redaction.test_kv_password_scrubbed_without_configured_pattern | ( | ) |
OI-506: ``password=…`` is redacted even with no REDACTION_PATTERNS.
Definition at line 103 of file test_redaction.py.
| test_redaction.test_openai_and_slack_prefixes_redacted | ( | ) |
OI-506: ``sk-…`` and ``xoxb-…`` tokens match the prefix regex.
Definition at line 90 of file test_redaction.py.
| test_redaction.test_redact_secrets_toggle_bypasses_builtins | ( | ) |
OI-506: with REDACT_SECRETS=False the three built-ins are inert.
Definition at line 132 of file test_redaction.py.
|
protected |
Definition at line 42 of file test_redaction.py.