test: guard against manifest push by digest reference

Signed-off-by: Terry Howe <terrylhowe@gmail.com>
pull/31394/head
Terry Howe 2 months ago
parent 123a317f78
commit f8fc960e8f
No known key found for this signature in database

@ -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 {

Loading…
Cancel
Save