Option C Tools
Loading...
Searching...
No Matches
tests_git.test_quality_gate_workspace_secrets Namespace Reference

Functions

Path _make_workspace (Path tmp_path, dict|None subproj_octrc)
 test_workspace_mode_baseline_flags_high_entropy (Path tmp_path)
 test_workspace_mode_module_self_doc_exclusion_applies (Path tmp_path)
 test_octrc_schema_accepts_module_self_doc_context ()
 test_octrc_schema_rejects_unknown_context ()

Variables

str HIGH_ENTROPY_FILE

Detailed Description

Purpose
-------
Regression coverage for the workspace-mode secret-scanner fix
(P2 of the drift resolution plan): when ``run_quality_gate_on_files``
runs from a workspace root, per-subproject ``entropy_exclusions``
configured in ``<sp>/.option_c/octrc.json`` must apply to files in
that subproject. Path patterns are prefixed with the subproject's
workspace-relative path. The new ``module_self_doc`` context value
must be honoured alongside ``test_directory`` for ``path_pattern``
exclusions and accepted by the octrc schema validator.

Responsibilities
----------------
- Build a minimal workspace + subproject + manifest.
- Plant a high-entropy string in a target Python file.
- Verify the scanner finds it WITHOUT a config (baseline).
- Verify the scanner skips it WITH a per-subproject ``module_self_doc``
  exclusion when invoked from the workspace root.
- Verify the schema validator accepts ``module_self_doc``.

Diagnostics
-----------
Domain: GIT-TESTS
Levels:
    L2 — test lifecycle
    L3 — per-assertion details

Contracts
---------
- Tests run hermetically inside ``tmp_path``; no real workspace is touched.
- Exclusion semantics are verified end-to-end through
  :func:`oct.git.quality_gate.run_quality_gate_on_files`.

Dependencies
------------
- oct.git.quality_gate (run_quality_gate_on_files entry point under test)
- oct.linter.oct_lint (_validate_octrc_schema for context validation)

Function Documentation

◆ _make_workspace()

Path tests_git.test_quality_gate_workspace_secrets._make_workspace ( Path tmp_path,
dict | None subproj_octrc )
protected
Build a minimal workspace at ``tmp_path/ws`` with one subproject.

Returns the workspace root.

Definition at line 93 of file test_quality_gate_workspace_secrets.py.

Here is the caller graph for this function:

◆ test_octrc_schema_accepts_module_self_doc_context()

tests_git.test_quality_gate_workspace_secrets.test_octrc_schema_accepts_module_self_doc_context ( )
The schema validator accepts the new ``module_self_doc`` context.

Definition at line 180 of file test_quality_gate_workspace_secrets.py.

◆ test_octrc_schema_rejects_unknown_context()

tests_git.test_quality_gate_workspace_secrets.test_octrc_schema_rejects_unknown_context ( )
Unknown ``context`` values are still rejected (regression guard).

Definition at line 198 of file test_quality_gate_workspace_secrets.py.

◆ test_workspace_mode_baseline_flags_high_entropy()

tests_git.test_quality_gate_workspace_secrets.test_workspace_mode_baseline_flags_high_entropy ( Path tmp_path)
Without any subproject octrc, the high-entropy literal is flagged.

Definition at line 126 of file test_quality_gate_workspace_secrets.py.

Here is the call graph for this function:

◆ test_workspace_mode_module_self_doc_exclusion_applies()

tests_git.test_quality_gate_workspace_secrets.test_workspace_mode_module_self_doc_exclusion_applies ( Path tmp_path)
Subproject's module_self_doc path_pattern is honoured at workspace scope.

The pattern ``help_text.py`` (subproject-relative) is prefixed with
``sub/`` by the workspace merge, so the workspace-relative file
path ``sub/help_text.py`` matches and entropy is exempted.

Definition at line 144 of file test_quality_gate_workspace_secrets.py.

Here is the call graph for this function:

Variable Documentation

◆ HIGH_ENTROPY_FILE

str tests_git.test_quality_gate_workspace_secrets.HIGH_ENTROPY_FILE

Definition at line 56 of file test_quality_gate_workspace_secrets.py.