MCPcopy Create free account
hub / github.com/docker/secrets-engine / TestDefaultKeyRewriter

Function TestDefaultKeyRewriter

plugins/credentialhelper/store_test.go:249–280  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

247}
248
249func TestDefaultKeyRewriter(t *testing.T) {
250 for _, tc := range []struct {
251 desc string
252 serverURL string
253 expected string
254 }{
255 {
256 desc: "valid URL with IP and without port",
257 serverURL: "http://127.0.0.1/something",
258 expected: "127.0.0.1/something",
259 },
260 {
261 desc: "URL with IP and Port",
262 serverURL: "http://192.162.233.123:8313/key/another",
263 expected: "192.162.233.123-port-8313/key/another",
264 },
265 {
266 desc: "URL with hostname",
267 serverURL: "https://docker.com/credential/key",
268 expected: "docker.com/credential/key",
269 },
270 {
271 desc: "trailing forward-slash",
272 serverURL: "https://example.com/credential/key/",
273 expected: "example.com/credential/key",
274 },
275 } {
276 t.Run(tc.desc, func(t *testing.T) {
277 assert.Equal(t, tc.expected, DefaultKeyRewriter(tc.serverURL))
278 })
279 }
280}

Callers

nothing calls this directly

Calls 2

DefaultKeyRewriterFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected