MCPcopy Index your code
hub / github.com/jetify-com/devbox / TestGetRedactedAuthHeader

Function TestGetRedactedAuthHeader

internal/plugin/github_test.go:140–176  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

138}
139
140func TestGetRedactedAuthHeader(t *testing.T) {
141 testCases := []struct {
142 name string
143 authHeader string
144 expected string
145 }{
146 {
147 "normal length token partially readable for debugging",
148 "token ghp_61b296fb898349778e20532cb65ce38e",
149 "token ghp_********************************",
150 },
151 {
152 "short token redacted",
153 "token ghp_61b29",
154 "token *********",
155 },
156 {
157 "short header fully redacted",
158 "token xyz",
159 "*********",
160 },
161 {
162 "no token returns empty string",
163 "",
164 "",
165 },
166 }
167
168 for _, testCase := range testCases {
169 t.Run(testCase.name, func(t *testing.T) {
170 req, err := http.NewRequest(http.MethodGet, "https://example.com", nil)
171 assert.NoError(t, err)
172 req.Header.Add("Authorization", testCase.authHeader)
173 assert.Equal(t, testCase.expected, getRedactedAuthHeader(req))
174 })
175 }
176}

Callers

nothing calls this directly

Calls 3

getRedactedAuthHeaderFunction · 0.85
RunMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected