High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
test: the request-body drop reason is stated as a literal, so renaming the scope constant can no longer pass (PIN-114)
Luigi Agosti8775d0fcf27d
diff --git a/internal/bridge/observe/network_body_clamp_test.go b/internal/bridge/observe/network_body_clamp_test.goindex 1621be5f..9154a9e1 100644--- a/internal/bridge/observe/network_body_clamp_test.go+++ b/internal/bridge/observe/network_body_clamp_test.go@@ -270,6 +270,14 @@ func TestBodyClampsAndDisplayFieldsUseTheirOwnHelper(t *testing.T) {if !strings.Contains(src, "clampRetainedBody(entry.PostData,") {t.Error("PostData no longer goes through clampRetainedBody: a second clamp beside it drifts, and PostData loses the drop-with-reason cases the response body already handles")}+ // The scope this site passes is the wording an operator reads in the drop reason, and the+ // branch that emits it cannot be reached through normalizeNetworkEntry — the cap is a+ // constant far larger than any rune — so no behavioural test can see which scope+ // production hands over. Read it from the source instead: passing a retention scope here+ // would tell an operator the RESPONSE budget refused their request body.+ if !strings.Contains(src, "maxNetworkPostDataBytes, postDataLimitScope)") {+ t.Error("the PostData clamp no longer passes postDataLimitScope, so its drop reason would name a budget that did not refuse the body")+ }if strings.Contains(src, "entry.PostData = sanitize.") {t.Error("PostData cuts with a sanitize helper directly again, bypassing the one payload clamp")}diff --git a/internal/bridge/observe/network_postdata_test.go b/internal/bridge/observe/network_postdata_test.goindex 9fd5690f..6a99a581 100644--- a/internal/bridge/observe/network_postdata_test.go+++ b/internal/bridge/observe/network_postdata_test.go@@ -336,16 +336,22 @@ func TestRequestEntryFlagsNothingForAnOrdinaryBody(t *testing.T) {// The sub-rune budget cannot arise through normalizeNetworkEntry — the cap is a constant far// larger than any rune — so the case is pinned where it lives, on the shared clamp, with the-// scope name this call site passes. That name is what an operator reads in the reason.+// scope name this call site passes. That name is what an operator reads in the reason, so the+// expectation is the SENTENCE, spelled out the way the response-body rows above spell theirs.+// Building it from postDataLimitScope instead would move with the constant: renaming the+// scope to the response-retention wording — telling an operator the retention budget refused+// their request body — would leave this test green while breaking the property it names.func TestTheRequestBodyScopeNamesItselfInTheDropReason(t *testing.T) {+ const wantReason = "request body limit is smaller than the body's first character"+for limit := 1; limit < 4; limit++ {clamped, truncated, reason := clampRetainedBody("🎯 body", false, limit, postDataLimitScope)if clamped != "" || truncated {t.Errorf("limit=%d: kept %q (truncated=%v) of a body whose first character does not fit", limit, clamped, truncated)}- if reason != postDataLimitScope+" is smaller than the body's first character" {- t.Errorf("limit=%d: reason = %q, which does not name the request body budget", limit, reason)+ if reason != wantReason {+ t.Errorf("limit=%d: reason = %q, want %q — the scope this site passes is what names the budget an operator reads", limit, reason, wantReason)}}if clamped, truncated, reason := clampRetainedBody("🎯 body", false, 4, postDataLimitScope); clamped != "🎯" || !truncated || reason != "" {