Repository navigation
test(proxy): serve proxy test upstreams locally - #213
Open
a-palamarchuk wants to merge 1 commit into
Open
a-palamarchuk wants to merge 1 commit into
a-palamarchuk wants to merge 1 commit into
Conversation
Five proxy tests forwarded allowed requests to dev.coder.com and jsonplaceholder.typicode.com over the internet. dev.coder.com now answers with a 301 to dogfood.cdr.dev, so TestProxyServerImplicitCONNECT and TestMultipleRequestsOverExplicitCONNECT fail on main, and the tests also fail wherever there is no internet. Add a WithFakeUpstream option that points the proxy's forward transport at local httptest servers (TLS for port 443, plain HTTP otherwise), plus a handler with the canned responses those hosts used to return. The tests keep their hostnames, so they still check that each request in a tunnel is forwarded to the host in its Host header. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Oct 3, 2026
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.
Problem
Five proxy tests forward allowed requests to
dev.coder.comandjsonplaceholder.typicode.comover the internet.dev.coder.comnow answers with301 Moved Permanentlytohttps://dogfood.cdr.dev/api/v2, so two tests fail onmain:The tests also fail or hang wherever there is no internet.
docs/agent-guide.mdalready asks proxy tests to avoid live network calls.Change
WithFakeUpstream(handler)option to the proxy test framework. It points the proxy's forward transport (the existingConfig.ForwardTransportseam) at two localhttptestservers: TLS for port 443 and plain HTTP for everything else.fakePublicHosts(), a handler that returns the canned responses those hosts used to return. It routes on theHostheader.Hostheader.Test-only change, no production code touched.
Testing
make unit-test: all packages pass.unshare -rn(loopback only). The same command onmaintimes out after 10 minutes.go test -race -count=5 -run 'TestProxyServerBasicHTTP$|TestProxyServerBasicHTTPS|TestProxyServerImplicitCONNECT|TestMultipleRequestsOverExplicitCONNECT|TestAuditURLIsFullyFormed_HTTPS' ./proxy/on the five changed tests: pass.make fmt-checkAI disclosure
I used Claude Code to investigate the failures and draft the change. I reviewed the diff and ran all of the checks above myself.