From b8c4c997e50ca201f16115ff45c9844554216af5 Mon Sep 17 00:00:00 2001 From: cshung <3410332+cshung@users.noreply.github.com> Date: Mon, 30 Nov 2026 18:45:59 +0000 Subject: [PATCH] test(registry): fix blob upload mock responses Preserve the incoming request on the mock upload response so relative Location headers can be resolved against the original registry URL. Return an upload-session path and handle the follow-up request at that path with 201 Created. This makes the mock compatible with the upload host validation introduced in ORAS 2.6.2 without weakening the validation or changing production code. It also unblocks the registry tests for the ORAS 2.7 upgrade in #598. Credit to siretart for documenting the root cause and providing this mock correction in the Debian investigation: https://github.com/notaryproject/notation-go/issues/587#issuecomment-5825162599 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3a297bdb-d8ae-492d-bae7-d555afa73630 Signed-off-by: cshung <3410332+cshung@users.noreply.github.com> --- registry/repository_test.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/registry/repository_test.go b/registry/repository_test.go index 17088ed7..efd35beb 100644 --- a/registry/repository_test.go +++ b/registry/repository_test.go @@ -157,11 +157,9 @@ func (c mockRemoteClient) Do(req *http.Request) (*http.Response, error) { return &http.Response{ StatusCode: http.StatusAccepted, Body: io.NopCloser(bytes.NewReader([]byte(msg))), - Request: &http.Request{ - Header: map[string][]string{}, - }, + Request: req, Header: map[string][]string{ - "Location": {"test"}, + "Location": {"/v2/test/blobs/uploads/test"}, }, }, nil default: @@ -203,7 +201,7 @@ func (c mockRemoteClient) Do(req *http.Request) (*http.Response, error) { URL: &url.URL{Path: "/v2/test/referrers/" + zeroDigest}, }, }, nil - case validRepo: + case "/v2/test/blobs/uploads/test", validRepo: return &http.Response{ StatusCode: http.StatusCreated, Body: io.NopCloser(bytes.NewReader([]byte(msg))),