(t *testing.T)
| 260 | } |
| 261 | |
| 262 | func 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 | |
| 288 | func TestWrongBasicAuthResolver(t *testing.T) { |
| 289 | creds := func(string) (string, string, error) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…