Skip to content

test(registry): fix blob upload mock responses - #604

Merged
yizha1 merged 2 commits into
notaryproject:mainfrom
cshung:users/yinghungau/registry-upload-mock
Nov 30, 2026
Merged

yizha1 merged 2 commits into
notaryproject:mainfrom
cshung:users/yinghungau/registry-upload-mock

Conversation

@cshung

@cshung cshung commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Correct the blob-upload responses in mockRemoteClient.Do:

  • Preserve the original HTTP request on the response so http.Response.Location() can resolve relative upload URLs against the registry URL.
  • Return /v2/test/blobs/uploads/test as the upload-session location.
  • Handle the follow-up upload request at that path with 201 Created.

The previous response had no request URL, so newer ORAS upload-host validation resolved the relative location without a registry host and rejected it. This repairs the mock rather than bypassing or weakening the host/scheme checks.

Only registry/repository_test.go changes. No production code, dependencies, Go minimum version, or error-message changes are included.

This applies the correction already documented in the Debian investigation.

Fixes #587. Related: #598.

Validation

With the current dependencies (ORAS 2.6.0):

  • Go 1.23.0: full uncached race-enabled SDK suite passed.
  • Go 1.24.0: uncached race-enabled registry suite passed.

In an isolated source snapshot inside the candidate checkout, with ORAS 2.7.0 and Go 1.26.0:

  • Reproduced the three upload-test failures using the original mock.
  • Applied this exact mock repair; the entire uncached race-enabled registry suite and go vet ./registry passed.
  • Temporary dependency changes were confined to the validation snapshot and are not part of this PR.

Formatting and git diff --check passed. These are local results; upstream CI is separate.

Copilot AI balanced review requested due to automatic review settings November 30, 2026 18:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the test-only registry upload mock update.

No open issues 🎉

What changed in this PR

Repairs the registry blob-upload test mock to support newer ORAS upload-host validation, addressing #587 without changing production code or dependencies.

Changes:

  • Preserves the original request so relative upload locations resolve against the registry URL.
  • Returns /v2/test/blobs/uploads/test as the upload-session location.
  • Handles the follow-up upload request with 201 Created.
File Description
registry/​repository_test.go Corrects mock response request metadata, upload location, and follow-up routing.

Review effort: Balanced

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 notaryproject#598.

Credit to siretart for documenting the root cause and providing this mock
correction in the Debian investigation:
notaryproject#587 (comment)

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>
@cshung
cshung force-pushed the users/yinghungau/registry-upload-mock branch from 18f5982 to b8c4c99 Compare November 30, 2026 18:52

@yizha1 yizha1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.94%. Comparing base (04c85a3) to head (78bf3ed).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #604   +/-   ##
=======================================
  Coverage   82.94%   82.94%           
=======================================
  Files          36       36           
  Lines        2645     2645           
=======================================
  Hits         2194     2194           
  Misses        310      310           
  Partials      141      141           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yizha1
yizha1 merged commit 696b555 into notaryproject:main Nov 30, 2026
9 checks passed
@cshung
cshung deleted the users/yinghungau/registry-upload-mock branch November 30, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade self-tests to deal with github.com/oras-project/oras-go v2.6.2 security release: FAIL: TestPushSignature

3 participants