From f8fc960e8f8a418d1e38e5c54de34883d2685132 Mon Sep 17 00:00:00 2001 From: Terry Howe Date: Fri, 10 Jul 2026 12:36:36 -0600 Subject: [PATCH] test: guard against manifest push by digest reference Signed-off-by: Terry Howe --- pkg/registry/client_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/registry/client_test.go b/pkg/registry/client_test.go index 690a51024..9f2eac3f4 100644 --- a/pkg/registry/client_test.go +++ b/pkg/registry/client_test.go @@ -199,6 +199,14 @@ func TestPushConcurrent(t *testing.T) { w.WriteHeader(http.StatusCreated) case r.Method == http.MethodPut && strings.Contains(r.URL.Path, "/manifests/"): + // The optimization pushes the manifest exactly once, by tag. A PUT to a + // digest reference (/manifests/sha256:...) means the manifest is being + // uploaded a second time by digest, which this test guards against. + if strings.Contains(r.URL.Path, "/manifests/sha256:") { + t.Errorf("unexpected manifest push by digest %q; manifest should be pushed once by tag", r.URL.Path) + w.WriteHeader(http.StatusBadRequest) + return + } // Manifest push - compute actual sha256 digest of the body body, err := io.ReadAll(r.Body) if err != nil {