MCPcopy
hub / github.com/containerd/containerd / TestBasicResolver

Function TestBasicResolver

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

Source from the content-addressed store, hash-verified

84}
85
86func TestBasicResolver(t *testing.T) {
87 basicAuth := func(h http.Handler) (string, ResolverOptions, func()) {
88 // Wrap with basic auth
89 wrapped := http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
90 username, password, ok := r.BasicAuth()
91 if !ok || username != "user1" || password != "password1" {
92 rw.Header().Set("WWW-Authenticate", "Basic realm=localhost")
93 rw.WriteHeader(http.StatusUnauthorized)
94 return
95 }
96 h.ServeHTTP(rw, r)
97 })
98
99 base, options, close := tlsServer(wrapped)
100 authorizer := NewDockerAuthorizer(
101 WithAuthClient(options.Client),
102 WithAuthCreds(func(host string) (string, string, error) {
103 return "user1", "password1", nil
104 }),
105 )
106 options.Hosts = ConfigureDefaultRegistries(
107 WithClient(options.Client),
108 WithAuthorizer(authorizer),
109 )
110 return base, options, close
111 }
112 runBasicTest(t, "testname", basicAuth)
113}
114
115func TestAnonymousTokenResolver(t *testing.T) {
116 th := http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 11

tlsServerFunction · 0.85
NewDockerAuthorizerFunction · 0.85
WithAuthClientFunction · 0.85
WithAuthCredsFunction · 0.85
WithClientFunction · 0.85
WithAuthorizerFunction · 0.85
HeaderMethod · 0.80
runBasicTestFunction · 0.70
SetMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…