MCPcopy
hub / github.com/containerd/containerd / TestResolveProxyFallback

Function TestResolveProxyFallback

core/remotes/docker/resolver_test.go:577–647  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

575}
576
577func TestResolveProxyFallback(t *testing.T) {
578 var (
579 ctx = context.Background()
580 tag = "latest"
581 r = http.NewServeMux()
582 name = "testname"
583 )
584
585 m := newManifest(
586 newContent(ocispec.MediaTypeImageConfig, []byte("1")),
587 newContent(ocispec.MediaTypeImageLayerGzip, []byte("2")),
588 )
589 mc := newContent(ocispec.MediaTypeImageManifest, m.OCIManifest())
590 m.RegisterHandler(r, name)
591 r.Handle(fmt.Sprintf("/v2/%s/manifests/%s", name, tag), mc)
592 r.Handle(fmt.Sprintf("/v2/%s/manifests/%s", name, mc.Digest()), mc)
593
594 nr := namespaceRouter{
595 "": r,
596 }
597 s := httptest.NewServer(logHandler{t, nr})
598 defer s.Close()
599
600 base := s.URL[len("http://"):]
601
602 ro := ResolverOptions{
603 Hosts: func(host string) ([]RegistryHost, error) {
604 return []RegistryHost{
605 {
606 Host: flipLocalhost(host),
607 Scheme: "http",
608 Path: "/v2",
609 Capabilities: HostCapabilityPull | HostCapabilityResolve,
610 },
611 {
612 Host: host,
613 Scheme: "http",
614 Path: "/v2",
615 Capabilities: HostCapabilityPull | HostCapabilityResolve | HostCapabilityPush,
616 },
617 }, nil
618 },
619 }
620
621 resolver := NewResolver(ro)
622 image := fmt.Sprintf("%s/%s:%s", base, name, tag)
623
624 _, d, err := resolver.Resolve(ctx, image)
625 if err != nil {
626 t.Fatal(err)
627 }
628 f, err := resolver.Fetcher(ctx, image)
629 if err != nil {
630 t.Fatal(err)
631 }
632
633 refs, err := testocimanifest(ctx, f, d)
634 if err != nil {

Callers

nothing calls this directly

Calls 14

ResolveMethod · 0.95
FetcherMethod · 0.95
flipLocalhostFunction · 0.85
NewResolverFunction · 0.85
testocimanifestFunction · 0.85
testFetchFunction · 0.85
FatalMethod · 0.80
newManifestFunction · 0.70
newContentFunction · 0.70
HandleMethod · 0.65
DigestMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…