MCPcopy Index your code
hub / github.com/containerd/containerd / TestWrongBasicAuthResolver

Function TestWrongBasicAuthResolver

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

Source from the content-addressed store, hash-verified

286}
287
288func TestWrongBasicAuthResolver(t *testing.T) {
289 creds := func(string) (string, string, error) {
290 return "totallyvaliduser", "definitelythewrongpassword", nil
291 }
292
293 ctx := context.Background()
294 h := newContent(ocispec.MediaTypeImageManifest, []byte("not anything parse-able"))
295
296 base, ro, close := withBasicAuthServer(creds)(logHandler{t, h})
297 defer close()
298
299 resolver := NewResolver(ro)
300 image := fmt.Sprintf("%s/doesntmatter:sometag", base)
301
302 _, _, err := resolver.Resolve(ctx, image)
303 if err == nil {
304 t.Fatal("Expected error getting token with inssufficient scope")
305 }
306 var rerr remoteerrors.ErrUnexpectedStatus
307 if !errors.As(err, &rerr) {
308 t.Fatal(err)
309 }
310 if rerr.StatusCode != 403 {
311 t.Fatalf("expected 403 status code, got %d", rerr.StatusCode)
312 }
313}
314
315func TestHostFailureFallbackResolver(t *testing.T) {
316 sf := func(h http.Handler) (string, ResolverOptions, func()) {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…