MCPcopy Create free account
hub / github.com/Shopify/goose / TestMapCustomSubstrings

Function TestMapCustomSubstrings

redact/redact_test.go:47–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

45}
46
47func TestMapCustomSubstrings(t *testing.T) {
48 oldSensitiveSubstrings := make([]string, len(GlobalSensitiveSubstrings))
49 copy(oldSensitiveSubstrings, GlobalSensitiveSubstrings)
50 defer func() {
51 GlobalSensitiveSubstrings = oldSensitiveSubstrings
52 }()
53
54 data := map[string]interface{}{"foo": "bar", "123": 456}
55
56 require.Equal(t, map[string]interface{}{"foo": "bar", "123": 456}, Map(data))
57
58 AddSensitiveSubstring("Foo")
59
60 require.Equal(t, map[string]interface{}{"foo": "[FILTERED]", "123": 456}, Map(data))
61
62 require.Equal(t, []string{
63 "authorization",
64 "cookie",
65 "token",
66 "password",
67 "secret",
68 "foo",
69 }, GlobalSensitiveSubstrings)
70}
71
72func TestHeaders(t *testing.T) {
73 testCases := []struct {

Callers

nothing calls this directly

Calls 2

MapFunction · 0.85
AddSensitiveSubstringFunction · 0.85

Tested by

no test coverage detected