Skip to content

Commit edf067b

Browse files
committed
fix(test): correct inv22 namespace gate assertions to match actual implementation
The test was looking for the wrong patterns: - UTF-8 check: error message string, not pre-loop condition - Namespace check: `*r == "refs/gitlawb"`, not `ref_name ==` - Visibility exemption: `&&` logic (both false to exclude), not `||`
1 parent b98eb2c commit edf067b

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎crates/gitlawb-node/tests/inv22_gates.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -863,10 +863,11 @@ fn issue_26_namespace_gate_and_refusal_wiring() {
863863

864864
// P1: fail the push on ref-update lines the handler cannot decode.
865865
// The gate at parse_ref_updates must refuse when any command line in the
866-
// ref-update section is undecodable UTF-8. The check is `!is_utf8()` on the
867-
// command bytes before the loop, so reverting it removes the gate.
866+
// ref-update section is undecodable UTF-8. The check is an Err arm on
867+
// `from_utf8(data)` that returns BadRequest, so removing it allows non-UTF-8
868+
// refs to bypass the namespace gate.
868869
assert!(
869-
repos.contains("if !std::str::from_utf8(ref_updates_bytes).is_ok()"),
870+
repos.contains("ref-update line is not valid UTF-8; push refused"),
870871
"P1 gate missing: parse_ref_updates must refuse when any ref-update line is \
871872
non-UTF-8 (git accepts bytes >= 0x80; the gate never sees them, no durable \
872873
child exists, and the lossy for-each-ref decode still matches the exemption)"
@@ -875,7 +876,7 @@ fn issue_26_namespace_gate_and_refusal_wiring() {
875876
// P1 (cont): the bare `refs/gitlawb` name must also be caught. The original
876877
// `starts_with("refs/gitlawb/")` misses it; the fix adds an explicit `==` arm.
877878
assert!(
878-
repos.contains("ref_name == \"refs/gitlawb\""),
879+
repos.contains("*r == \"refs/gitlawb\""),
879880
"P1 gate missing: the namespace check must match the bare 'refs/gitlawb' name \
880881
(starts_with('refs/gitlawb/') misses it, and it lands on repos with no internal \
881882
refs yet)"
@@ -907,8 +908,7 @@ fn issue_26_namespace_gate_and_refusal_wiring() {
907908
// gate works, which the P1 findings above covered (non-UTF-8 line, bare name,
908909
// refusal wiring). This check verifies the exemption narrowing landed.
909910
assert!(
910-
vis.contains(r#"ref_name.starts_with("refs/gitlawb/requests/")"#)
911-
|| vis.contains(r#"ref_name.starts_with("refs/gitlawb/issues/")"#),
911+
vis.contains(r#"!r.starts_with("refs/gitlawb/requests/") && !r.starts_with("refs/gitlawb/issues/")"#),
912912
"P2 gate missing: the visibility exemption must be narrowed to requests/ and \
913913
issues/ only (the push gate is the premise; any other refs/gitlawb/* ref is \
914914
denied on push and must fail closed in the pack path)"

0 commit comments

Comments
 (0)