MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / assertQueryVectorIntact

Function assertQueryVectorIntact

internal/server/middleware_query_test.go:31–47  ·  view source on GitHub ↗

assertQueryVectorIntact fails if the request Go builds from target does not actually deliver invalid query text to a handler — i.e. if the premise of the assertions below has stopped holding. Without this, a future change to how net/url decodes a query would silently turn every case in this file int

(t *testing.T, target string)

Source from the content-addressed store, hash-verified

29// It asserts against r.URL.Query(), because that is what handlers read and
30// therefore what "reaches the store" means for the query string.
31func assertQueryVectorIntact(t *testing.T, target string) {
32 t.Helper()
33 req := httptest.NewRequest("GET", target, nil)
34 for key, values := range req.URL.Query() {
35 if !bindableText(key) {
36 return
37 }
38 for _, v := range values {
39 if !bindableText(v) {
40 return
41 }
42 }
43 }
44 t.Fatalf("premise broken: %q parses to a query whose keys and values are all "+
45 "already valid text (%#v); this test can no longer exercise BUG-2784's vector",
46 target, req.URL.Query())
47}
48
49// TestValidateQueryRejectsUnbindableQueryText drives the REAL server rather
50// than ValidateQuery directly, so it vouches for the middleware's BINDING as

Calls 4

bindableTextFunction · 0.85
HelperMethod · 0.80
FatalfMethod · 0.80
QueryMethod · 0.65

Tested by

no test coverage detected