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

Function TestRedactQueryString

internal/server/middleware_logging_test.go:13–95  ·  view source on GitHub ↗

TestRedactQueryString covers the F6 leak guard: sensitive keys (token, password, secret, api_key / api-key) must have their values replaced with REDACTED before the structured request logger writes them to disk. Other keys must be untouched so logs remain useful for diagnosis.

(t *testing.T)

Source from the content-addressed store, hash-verified

11// disk. Other keys must be untouched so logs remain useful for
12// diagnosis.
13func TestRedactQueryString(t *testing.T) {
14 t.Parallel()
15 cases := []struct {
16 name string
17 in string
18 want string
19 }{
20 {
21 name: "empty",
22 in: "",
23 want: "",
24 },
25 {
26 name: "no sensitive keys",
27 in: "ref=TASK-5&limit=20",
28 want: "ref=TASK-5&limit=20",
29 },
30 {
31 name: "token alone",
32 in: "token=abc123",
33 want: "token=REDACTED",
34 },
35 {
36 name: "token mid-string",
37 in: "ref=TASK-5&token=abc123&limit=20",
38 want: "ref=TASK-5&token=REDACTED&limit=20",
39 },
40 {
41 name: "token at end",
42 in: "ref=TASK-5&token=abc123",
43 want: "ref=TASK-5&token=REDACTED",
44 },
45 {
46 name: "case-insensitive",
47 in: "TOKEN=abc123",
48 want: "TOKEN=REDACTED",
49 },
50 {
51 name: "password",
52 in: "password=hunter2",
53 want: "password=REDACTED",
54 },
55 {
56 name: "secret",
57 in: "secret=topsecret",
58 want: "secret=REDACTED",
59 },
60 {
61 name: "api_key underscore",
62 in: "api_key=abc",
63 want: "api_key=REDACTED",
64 },
65 {
66 name: "api-key dash",
67 in: "api-key=abc",
68 want: "api-key=REDACTED",
69 },
70 {

Callers

nothing calls this directly

Calls 3

RedactQueryFunction · 0.92
FatalfMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected