(t *testing.T)
| 286 | } |
| 287 | |
| 288 | func 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 | |
| 315 | func TestHostFailureFallbackResolver(t *testing.T) { |
| 316 | sf := func(h http.Handler) (string, ResolverOptions, func()) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…