8OI-504 regression tests — ``_load_debug_config_patterns()`` must look up
9``debug_config.json`` at ``<root>/oc_diagnostics/debug_config.json`` first
10(the canonical location since v0.9.0) and fall back to the legacy
11``<root>/debug_config.json`` only when the canonical path is absent.
15- Canonical ``oc_diagnostics/debug_config.json`` is preferred when present.
16- Legacy root-level ``debug_config.json`` is still read when the canonical
18- Neither path present → returns ``[]`` (safe default, no raise).
25 L3 — assertion details
30- Function never raises; returns a list.
34from pathlib
import Path
40_CANONICAL_PATTERNS = [{
"name":
"canonical",
"pattern":
"CANONICAL-SECRET"}]
41_LEGACY_PATTERNS = [{
"name":
"legacy",
"pattern":
"LEGACY-SECRET"}]
45 return McpConfig(trust_repo_config=
True, profile=
"default")
49 (tmp_path /
"oc_diagnostics").mkdir()
50 (tmp_path /
"oc_diagnostics" /
"debug_config.json").write_text(
51 json.dumps({
"redaction_patterns": _CANONICAL_PATTERNS}),
55 (tmp_path /
"debug_config.json").write_text(
56 json.dumps({
"redaction_patterns": _LEGACY_PATTERNS}),
60 patterns = _load_debug_config_patterns(tmp_path,
_make_config())
62 assert patterns == _CANONICAL_PATTERNS
66 (tmp_path /
"debug_config.json").write_text(
67 json.dumps({
"redaction_patterns": _LEGACY_PATTERNS}),
71 patterns = _load_debug_config_patterns(tmp_path,
_make_config())
73 assert patterns == _LEGACY_PATTERNS
77 patterns = _load_debug_config_patterns(tmp_path,
_make_config())
test_canonical_path_preferred(Path tmp_path)
test_legacy_path_used_when_canonical_absent(Path tmp_path)
test_neither_path_returns_empty(Path tmp_path)