MCPcopy
hub / github.com/containerd/containerd / TestMissingBasicAuthResolver

Function TestMissingBasicAuthResolver

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

Source from the content-addressed store, hash-verified

260}
261
262func TestMissingBasicAuthResolver(t *testing.T) {
263 creds := func(string) (string, string, error) {
264 return "", "", nil
265 }
266
267 ctx := context.Background()
268 h := newContent(ocispec.MediaTypeImageManifest, []byte("not anything parse-able"))
269
270 base, ro, close := withBasicAuthServer(creds)(logHandler{t, h})
271 defer close()
272
273 resolver := NewResolver(ro)
274 image := fmt.Sprintf("%s/doesntmatter:sometag", base)
275
276 _, _, err := resolver.Resolve(ctx, image)
277 if err == nil {
278 t.Fatal("Expected error getting token with inssufficient scope")
279 }
280 if !errors.Is(err, ErrInvalidAuthorization) {
281 t.Fatal(err)
282 }
283 if !strings.Contains(err.Error(), "no basic auth credentials") {
284 t.Fatalf("expected \"no basic auth credentials\" message, got %s", err.Error())
285 }
286}
287
288func TestWrongBasicAuthResolver(t *testing.T) {
289 creds := func(string) (string, string, error) {

Callers

nothing calls this directly

Calls 6

ResolveMethod · 0.95
withBasicAuthServerFunction · 0.85
NewResolverFunction · 0.85
FatalMethod · 0.80
newContentFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…