Skip to content

Make the get goal's repository tests capable of failing - #1678

Merged
slachiewicz merged 1 commit into
masterfrom
agent/mdep-get-test-hardening
Aug 9, 2026
Merged

slachiewicz merged 1 commit into
masterfrom
agent/mdep-get-test-hardening

Conversation

@slachiewicz

@slachiewicz slachiewicz commented Aug 9, 2026 •

Copy link
Copy Markdown
Member

testRemoteRepositoriesAuthentication was not testing anything. Once any run has resolved test:test:1.0, it persists in the local repository the tests share under target/test-classes/unit/get-test/target/local-repo, so on any subsequent run without a clean the artifact is served from there and the test passes with GetMojo's injectAuthentication call deleted outright.

It now resolves into a @TempDir local repository, so the assertion depends on the transfer actually happening. The two paths that had no test at all are covered too:

  • an active <proxy> from the settings must be applied to the repositories named by remoteRepositories;
  • <nonProxyHosts> must exclude a repository from a proxy that would otherwise match it.

The proxy points at a name in a reserved TLD (RFC 2606) that cannot resolve, so applying it is always observable as a failure, and the test asserts the failure message mentions that host — it cannot pass because the artifact was missing or the login was rejected. The nonProxyHosts test asserts a success, so on its own it cannot tell "honoured" from "proxies never applied"; that is noted in the test so the pair does not get split up later.

Verification. Against this branch: 6/6 pass. With the three injectMirror/injectProxy/injectAuthentication calls deleted from GetMojo, testRemoteRepositoriesAuthentication, testRemoteRepositoriesProxy and testRemoteRepositoriesNonProxyHosts all fail. So these characterise the behaviour rather than merely agreeing with the current implementation.

Test-only; no src/main change. First of three pieces split out of #1677 — merge order #1678 → #1677 → #1679. It stands on its own, and it is what lets the follow-ups show that the mirror/proxy/credential behaviour survives the refactor.

Drafted with Claude — please verify

@slachiewicz slachiewicz added the java Pull requests that update Java code label Aug 9, 2026
@slachiewicz
slachiewicz marked this pull request as ready for review August 9, 2026 19:41
testRemoteRepositoriesAuthentication was not testing anything. Once any run has
resolved test:test:1.0, it persists in the local repository the tests share
under target/test-classes/unit/get-test/target/local-repo, so on any subsequent
run without a clean the artifact is served from there and the test passes even
with GetMojo's injectAuthentication call deleted outright.

Resolve into a @tempdir local repository instead, so the assertion depends on
the transfer actually happening, and cover the two paths that had no test at
all: an active proxy from the settings must be applied to the repositories
named by remoteRepositories, and nonProxyHosts must exclude a repository from
it. The proxy points at a name in a reserved TLD that cannot resolve, so
applying it is always observable, and the test asserts the failure mentions
that host -- it cannot pass because the artifact was missing or the login was
rejected.

The nonProxyHosts test asserts a success, so it only distinguishes "honoured"
from "proxies never applied" when read together with the proxy test; that is
noted on it so the pair is not split up later.

With this in place, deleting the three inject calls from GetMojo fails all
three tests.

Generated-by: Claude Opus 5 (1M context)

Copilot AI 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.

Pull request overview

This PR hardens dependency:get unit tests so they genuinely validate repository authentication/proxy behavior by eliminating false positives caused by artifacts persisting in a shared local test repository.

Changes:

  • Isolates resolution into a per-test @TempDir local repository to ensure transfers actually occur.
  • Adds coverage for proxy application to remoteRepositories and for nonProxyHosts excluding a repository from proxying.
  • Refactors test utilities to centralize server URL construction and proxy detection in failure chains.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@slachiewicz
slachiewicz merged commit 6127099 into master Aug 9, 2026
21 of 22 checks passed
@slachiewicz
slachiewicz deleted the agent/mdep-get-test-hardening branch August 9, 2026 20:21
@github-actions github-actions Bot added this to the 3.11.1 milestone Aug 9, 2026
@slachiewicz slachiewicz added the bug Something isn't working label Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working java Pull requests that update Java code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants