Orchestrata Ultimate › Tests › Reference › scripts › test_claude_governance_gate

Tests reference — tests/scripts/test_claude_governance_gate.py

Module of tests/scripts, split out because the directory page would be too large.

Prose pending.

tests/scripts/test_claude_governance_gate.py

source · 47 tests · 729 lines

Tests for scripts/claude_governance_gate.py — the ADR-0032 admission-

Covers: core.adapters.claude.tool_interceptor

Kind Name Line Description
class TestMainAllowPath 72
method TestMainAllowPath.test_allow_produces_no_stdout 73
method TestMainAllowPath.test_allow_writes_audit_log 79
method TestMainAllowPath.test_no_audit_log_env_means_no_file_written 94
class TestMainInterceptorErrorFailsClosedByDefault 101 The interceptor call itself can raise on genuinely malformed input --
method TestMainInterceptorErrorFailsClosedByDefault.test_unhashable_tool_name_blocks_under_default_fail_closed 110
method TestMainInterceptorErrorFailsClosedByDefault.test_unhashable_tool_name_writes_block_audit_entry 121
method TestMainInterceptorErrorFailsClosedByDefault.test_unhashable_tool_name_allows_under_declared_fail_open 134
class TestMainMalformedInputBlocksUnderFailClosed 154
method TestMainMalformedInputBlocksUnderFailClosed.test_malformed_json_blocks_by_default 155
method TestMainMalformedInputBlocksUnderFailClosed.test_non_dict_json_blocks_by_default 163
method TestMainMalformedInputBlocksUnderFailClosed.test_empty_stdin_blocks_by_default 171
method TestMainMalformedInputBlocksUnderFailClosed.test_malformed_json_allows_under_declared_fail_open 179
class TestMainTimeout 193 A REAL slow evaluation via a REAL ToolInterceptor with a real
method TestMainTimeout.test_timeout_blocks_by_default 210
method TestMainTimeout.test_timeout_allows_under_declared_fail_open 222
class TestMainNonDictToolInputBlocksUnderFailClosed 242 A tool_input that survives JSON parsing but is not a JSON object
method TestMainNonDictToolInputBlocksUnderFailClosed.test_string_tool_input_blocks_by_default 249
method TestMainNonDictToolInputBlocksUnderFailClosed.test_list_tool_input_blocks_by_default 262
method TestMainNonDictToolInputBlocksUnderFailClosed.test_number_tool_input_allows_under_declared_fail_open 275
method TestMainNonDictToolInputBlocksUnderFailClosed.test_subprocess_non_dict_tool_input_blocks_not_crashes 288
class TestMainFailOpenWithoutReasonFallsBackToFailClosed 306 Declaring FAIL_OPEN without a reason must never crash the gate --
method TestMainFailOpenWithoutReasonFallsBackToFailClosed.test_load_declaration_falls_back_to_fail_closed 312
method TestMainFailOpenWithoutReasonFallsBackToFailClosed.test_main_does_not_crash_and_blocks_malformed_input 319
method TestMainFailOpenWithoutReasonFallsBackToFailClosed.test_subprocess_does_not_crash 330
class TestMainSelfExclusion 347
method TestMainSelfExclusion.test_self_exclusion_short_circuits_to_allow 348
method TestMainSelfExclusion.test_self_exclusion_bypasses_even_an_unhashable_payload_hazard 367
method TestMainSelfExclusion.test_non_matching_tool_does_not_self_exclude 386
class TestMainModifyWiring 398 The interceptor computes a mutation (a real transformer function
method TestMainModifyWiring.test_modify_emits_updated_input 417
method TestMainModifyWiring.test_modify_writes_modify_audit_entry 432
method TestMainModifyWiring.test_mutation_application_is_idempotent 445 Applying the gate to an already-mutated input yields the same
class TestMainModifyWithNoModifiedInputIsEngineError 474 A real transformer that returns None produces a real MODIFY
method TestMainModifyWithNoModifiedInputIsEngineError.test_blocks_by_default 498
method TestMainModifyWithNoModifiedInputIsEngineError.test_allows_under_declared_fail_open 513
class TestOutcomeForDecisionValue 533 Direct unit coverage of the raw-decision-value -> GateOutcome mapping,
method TestOutcomeForDecisionValue.test_allow 539
method TestOutcomeForDecisionValue.test_block 542
method TestOutcomeForDecisionValue.test_modify 545
method TestOutcomeForDecisionValue.test_delay_is_conservatively_an_engine_error 548
method TestOutcomeForDecisionValue.test_unknown_value_is_conservatively_an_engine_error 554
class TestMainBlockWiring 561 A real deny-list BLOCK (ToolInterceptor.deny_tool() -- a real,
method TestMainBlockWiring.test_block_emits_deny 575
method TestMainBlockWiring.test_block_writes_block_audit_entry 589
class TestEmitDeny 602 Direct unit coverage of the deny-output formatter -- see module
method TestEmitDeny.test_emit_deny_shape 607
class TestEmitAllowWithUpdate 620
method TestEmitAllowWithUpdate.test_emit_allow_with_update_shape 621
class TestAppendAuditLog 635
method TestAppendAuditLog.test_appends_jsonl_line 636
method TestAppendAuditLog.test_noop_when_path_falsy 649
method TestAppendAuditLog.test_write_failure_is_swallowed 655
class TestLoadDeclaration 664
method TestLoadDeclaration.test_defaults_to_fail_closed 665
method TestLoadDeclaration.test_invalid_policy_value_falls_back_to_fail_closed 670
method TestLoadDeclaration.test_invalid_timeout_falls_back_to_default 676
method TestLoadDeclaration.test_non_positive_timeout_falls_back_to_default 682
method TestLoadDeclaration.test_explicit_valid_timeout_is_used 686
method TestLoadDeclaration.test_declared_fail_open_with_reason 692
class TestMainRealSubprocess 703 One genuinely-real-execution test per the brief: invoke the script
method TestMainRealSubprocess.test_subprocess_allow_path 707
method TestMainRealSubprocess.test_subprocess_malformed_stdin_blocks_by_default 718