Skip to content

test(cli): clear service-specific AWS endpoint overrides in every test stub - #2227

Merged
cristim merged 1 commit into
mainfrom
test/endpoint-env-overrides
Oct 16, 2026
Merged

cristim merged 1 commit into
mainfrom
test/endpoint-env-overrides

Conversation

@cristim

@cristim cristim commented Oct 16, 2026

Copy link
Copy Markdown
Member

Closes #2222

Summary

Some test stubs pointed the AWS SDK at a local server by setting only AWS_ENDPOINT_URL or a single service-specific URL. A developer's own environment could defeat that in two ways:

  • A service-specific override such as AWS_ENDPOINT_URL_RDS takes precedence.
  • AWS_IGNORE_CONFIGURED_ENDPOINT_URLS=true makes the SDK ignore the env endpoints entirely.

When that happens, the tests go off-host.

This PR moves the endpoint-clearing loop that #2225 added in isolateAWSEnv into one helper, clearAWSEndpointOverrides(t), in cmd/multi_service_test.go. The helper blanks every AWS_ENDPOINT_URL_* variable found in os.Environ() and clears AWS_IGNORE_CONFIGURED_ENDPOINT_URLS. It is now used by:

  • isolateAWSEnv
  • rdsAPIStub.serveEnv, which still sets AWS_ENDPOINT_URL and _COST_EXPLORER after the clear
  • startGCPInterruptChild, before it launches the child. The child inherits os.Environ() and then sets its own secretsmanager URL.
  • purchase_confirmation_test.go, before its explicit AWS_ENDPOINT_URL / _RDS / _EC2 lines

The change is test-only.

Evidence

All runs are local, on macOS, with GOTOOLCHAIN=go1.26.9. They use fixtures and a CONNECT-logging proxy.

  • Before: the hostile env (AWS_ENDPOINT_URL_RDS=https://rds.example.invalid, AWS_IGNORE_CONFIGURED_ENDPOINT_URLS=true, fake creds) fails -run 'ExclusionDataUnavailable|ExtendedSupportDataUnavailable|GCP'. The proxy logged 2 CONNECTs to secretsmanager and about 38 to rds.example.invalid.
  • After: the same run passes with 0 CONNECTs. An independent reviewer reproduced this (96 tests). The confirmation tests also pass with hostile _STS, _COST_EXPLORER and _ORGANIZATIONS.
  • Mutation probe: removing the helper call in serveEnv makes ExtendedSupportDataUnavailable fail under the hostile env.
  • Known limit: removing the call in startGCPInterruptChild does not fail a test. Only the CONNECT count shows it. test(cli): fail the cmd package on any off-host request #2221's package-level off-host guard would turn this into a test failure.
  • Checks: make build, go vet ./... and go test -race ./cmd/... pass. golangci-lint v2.10.1 reports 0 issues. scripts/test-git-secrets-allowlist.sh passes 44/44.
  • Review: two passes by an independent non-author reviewer (sonnet, high). Pass 2 raised an optional low about purchase_confirmation_test.go, now applied. The final confirmation found no actionable findings at 0edd8e1.

🤖 Generated with Claude Code

…t stub

Shared clearAWSEndpointOverrides helper blanks AWS_ENDPOINT_URL_* and
AWS_IGNORE_CONFIGURED_ENDPOINT_URLS; used by isolateAWSEnv, rdsAPIStub.serveEnv
and the GCP signal child launcher.

Closes #2222

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cristim cristim added priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/eventually No deadline impact/internal Team-internal only effort/xs Trivial / one-liner type/bug Defect triaged Item has been triaged labels Oct 16, 2026
@coderabbitai

coderabbitai Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 4 billable files and costs up to $1.00.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 20 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 64 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-cli/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 00b91244-ca0b-4913-b980-9ce3b9c29112
📥 Commits

Reviewing files that changed from the base of the PR and between 52ad82f and 0edd8e1.

📒 Files selected for processing: 4
  • cmd/configure_gcp_signal_test.go
  • cmd/multi_service_extended_support_unavailable_test.go
  • cmd/multi_service_test.go
  • cmd/purchase_confirmation_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@cristim

cristim commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Independent review verdict: CLEAN at 0edd8e1

Reviewer: fresh Claude agent (Sonnet, high effort), not the author. Coordinator: claude-cc-reviewer.

What was checked:

  • Every stub covered: every AWS_ENDPOINT_URL stub in cmd/*_test.go now goes through clearAWSEndpointOverrides (multi_service_test.go:1655): isolateAWSEnv (:1691), rdsAPIStub.serveEnv (multi_service_extended_support_unavailable_test.go:164), startGCPInterruptChild (configure_gcp_signal_test.go:150) and purchase_confirmation_test.go:153. The child's own AWS_ENDPOINT_URL_SECRETS_MANAGER (configure_gcp_signal_test.go:227) is set after the clear. No unguarded stub remains.
  • Reuse: the inline loop from isolateAWSEnv moved into the one shared helper, so nothing is duplicated.
  • Reproduction: on origin/main, hostile AWS_ENDPOINT_URL_<SERVICE> overrides make TestFetchEngineVersionData_ExclusionDataUnavailable and TestFilterAndAdjustRecommendations_ExtendedSupportDataUnavailable fail with an EC2 endpoint resolution error. At this head they pass.
  • go vet ./cmd/... is clean, and go test -race -count=1 ./cmd/... passes 1469.

Gate:

@cristim
cristim merged commit cfdfdf2 into main Oct 16, 2026
12 checks passed
@cristim
cristim deleted the test/endpoint-env-overrides branch October 16, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/xs Trivial / one-liner impact/internal Team-internal only priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/bug Defect urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(cli): rdsAPIStub ignores service-specific AWS endpoint overrides

1 participant