MCPcopy
hub / github.com/google/go-containerregistry / TestRedactFetchBlob

Function TestRedactFetchBlob

pkg/v1/remote/descriptor_test.go:225–242  ·  view source on GitHub ↗

TestRedactFetchBlob tests that a request to fetchBlob that gets redirected to a URL that contains sensitive information has that information redacted if the subsequent request fails.

(t *testing.T)

Source from the content-addressed store, hash-verified

223// to a URL that contains sensitive information has that information redacted
224// if the subsequent request fails.
225func TestRedactFetchBlob(t *testing.T) {
226 ctx := context.Background()
227 f := fetcher{
228 target: mustNewTag(t, "original.com/repo:latest").Context(),
229 client: &http.Client{
230 Transport: errTransport{},
231 },
232 }
233 h, err := v1.NewHash(fakeDigest)
234 if err != nil {
235 t.Fatal("NewHash:", err)
236 }
237 if _, err := f.fetchBlob(ctx, 0, h); err == nil {
238 t.Fatalf("fetchBlob: expected error, got nil")
239 } else if !strings.Contains(err.Error(), "access_token=REDACTED") {
240 t.Fatalf("fetchBlob: expected error to contain redacted access token, got %v", err)
241 }
242}
243
244type errTransport struct{}
245

Callers

nothing calls this directly

Calls 5

fetchBlobMethod · 0.95
NewHashFunction · 0.92
mustNewTagFunction · 0.85
ContextMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…