MCPcopy Create free account
hub / github.com/containers/image / TestRegistryConfigurationSignatureTopLevel

Function TestRegistryConfigurationSignatureTopLevel

docker/registries_d_test.go:226–272  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

224}
225
226func TestRegistryConfigurationSignatureTopLevel(t *testing.T) {
227 config := registryConfiguration{
228 DefaultDocker: &registryNamespace{Lookaside: "=default", LookasideStaging: "=default+w"},
229 Docker: map[string]registryNamespace{},
230 }
231 for _, ns := range []string{
232 "localhost",
233 "localhost:5000",
234 "example.com",
235 "example.com/ns1",
236 "example.com/ns1/ns2",
237 "example.com/ns1/ns2/repo",
238 "example.com/ns1/ns2/repo:notlatest",
239 } {
240 config.Docker[ns] = registryNamespace{Lookaside: ns, LookasideStaging: ns + "+w"}
241 }
242
243 for _, c := range []struct{ input, expected string }{
244 {"example.com/ns1/ns2/repo:notlatest", "example.com/ns1/ns2/repo:notlatest"},
245 {"example.com/ns1/ns2/repo:unmatched", "example.com/ns1/ns2/repo"},
246 {"example.com/ns1/ns2/notrepo:notlatest", "example.com/ns1/ns2"},
247 {"example.com/ns1/notns2/repo:notlatest", "example.com/ns1"},
248 {"example.com/notns1/ns2/repo:notlatest", "example.com"},
249 {"unknown.example.com/busybox", "=default"},
250 {"localhost:5000/busybox", "localhost:5000"},
251 {"localhost/busybox", "localhost"},
252 {"localhost:9999/busybox", "=default"},
253 } {
254 dr := dockerRefFromString(t, "//"+c.input)
255
256 res := config.signatureTopLevel(dr, false)
257 assert.Equal(t, c.expected, res, c.input)
258 res = config.signatureTopLevel(dr, true) // test that forWriting is correctly propagated
259 assert.Equal(t, c.expected+"+w", res, c.input)
260 }
261
262 config = registryConfiguration{
263 Docker: map[string]registryNamespace{
264 "unmatched": {Lookaside: "a", LookasideStaging: "b"},
265 },
266 }
267 dr := dockerRefFromString(t, "//thisisnotmatched")
268 res := config.signatureTopLevel(dr, false)
269 assert.Equal(t, "", res)
270 res = config.signatureTopLevel(dr, true)
271 assert.Equal(t, "", res)
272}
273
274func TestRegistryNamespaceSignatureTopLevel(t *testing.T) {
275 for _, c := range []struct {

Callers

nothing calls this directly

Calls 2

signatureTopLevelMethod · 0.95
dockerRefFromStringFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…