Repository navigation
test(cli): fail the cmd package on any off-host request - #2229
Merged
Merged
Conversation
TestMain starts a local listener, points the proxy env vars at it and records and refuses every proxied request. After m.Run the package exits 1 naming the hosts if any were recorded. Loopback stays exempt via NO_PROXY. Closes #2221 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Member
Author
Independent review verdict: CLEAN at 4606facReviewer: fresh Claude agent (Sonnet, high effort), not the author. Coordinator: claude-cc-reviewer. What was checked:
Non-blocking: GCP and Azure SDK clients were not probed; the body lists Gate:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2221
Summary
#2215, #2225 and #2227 removed the
cmdtests' off-host requests. Nothing stopped a new test from adding one back: without credentials, an SDK call just fails slowly, and the test often still passes. This PR adds a package-level guard so that any off-host request fails the package.cmd/offhost_guard_test.go(new) starts a local proxy that records and refuses every proxied request, CONNECT and plain-HTTP absolute-URI alike.TestMainpointsHTTP_PROXY/HTTPS_PROXY(both upper- and lower-case) at that proxy.NO_PROXYcovers loopback, so httptest servers and the SDK's loopback stubs keep working; Go's proxy logic always bypasses localhost and loopback IPs anyway.m.Run(), if anything was recorded, the package prints the hosts and exits 1, even when every test passed.CUDLY_TEST_OFFHOST_GUARDmarker keeps a child from installing a second guard. That second guard would overwrite a proxy the parent set on purpose (purchase_confirmation_test.go:150).CUDLY_COMPLETENESS_CHILDis set.Blind spots, documented in the helper:
Proxy: nil(configure_gcp_iam_test.go:154,configure_gcp_signal_test.go:220).Evidence
All runs are local on macOS with
GOTOOLCHAIN=go1.26.9.go test -race ./cmd/passes with 0 recorded requests.http.Get("https://example.com")andhttp.Get("http://example.org/x")makes the package exit 1 withFAIL: tests made off-host requests, listingCONNECT example.com:443andGET example.org. The author and an independent reviewer each reproduced this. A failing test still exits non-zero.purchase_confirmation_test.gosets.go test ./cmd/ -shuffle=on -count=2passes.make buildpasses,go vet ./...is clean, golangci-lint v2.10.1 reports 0 issues, andscripts/test-git-secrets-allowlist.shpasses 44/44.PASSline, but the exit code is correct.🤖 Generated with Claude Code
Summary by CodeRabbit