Skip to content

🌱 tests: add unit and e2e tests for HTTPS_PROXY support#2654

Open
tmshort wants to merge 1 commit intooperator-framework:mainfrom
tmshort:proxy-tests
Open

🌱 tests: add unit and e2e tests for HTTPS_PROXY support#2654
tmshort wants to merge 1 commit intooperator-framework:mainfrom
tmshort:proxy-tests

Conversation

@tmshort
Copy link
Copy Markdown
Contributor

@tmshort tmshort commented Apr 15, 2026

Unit tests verify that BuildHTTPClient correctly tunnels HTTPS connections through a proxy and fails when the proxy rejects the CONNECT request.

E2e tests cover two scenarios: a dead proxy that blocks catalog fetches (asserted via "proxyconnect" in the Retrying condition), and a live recording proxy that asserts catalog traffic actually routes through it via CONNECT.

Description

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

Unit tests verify that BuildHTTPClient correctly tunnels HTTPS
connections through a proxy and fails when the proxy rejects the
CONNECT request.

E2e tests cover two scenarios: a dead proxy that blocks catalog
fetches (asserted via "proxyconnect" in the Retrying condition), and
a live recording proxy that asserts catalog traffic actually routes
through it via CONNECT.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Todd Short <tshort@redhat.com>
Copilot AI review requested due to automatic review settings April 15, 2026 21:38
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 15, 2026

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit edaa59e
🔍 Latest deploy log https://app.netlify.com/projects/olmv1/deploys/69e005444507750008ae83de
😎 Deploy Preview https://deploy-preview-2654--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@openshift-ci openshift-ci bot requested review from oceanc80 and perdasilva April 15, 2026 21:38
@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Apr 15, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign grokspawn for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds unit + e2e test coverage around HTTPS proxying for catalog traffic, including new godog steps to reconfigure controller deployments and a lightweight “recording proxy” used to assert CONNECT tunneling.

Changes:

  • Register new proxy-related godog steps and add scenario cleanup to revert modified deployments / stop the proxy.
  • Add new e2e feature scenarios for “dead proxy blocks fetch” and “recording proxy observes CONNECT to catalogd”.
  • Add unit tests intended to validate HTTPS CONNECT proxy tunneling behavior for BuildHTTPClient.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
test/e2e/steps/steps.go Registers proxy step definitions in the e2e step registry.
test/e2e/steps/proxy_steps.go Implements deployment env patching helpers and an in-process CONNECT recording proxy.
test/e2e/steps/hooks.go Adds scenario context fields and cleanup to stop proxy + restore deployments.
test/e2e/features/proxy.feature Adds two e2e scenarios covering dead proxy and recording proxy routing assertions.
internal/shared/util/http/httputil_test.go Adds unit tests around proxy CONNECT tunneling behavior for BuildHTTPClient.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +91 to +97
// The test overrides the transport's Proxy function with http.ProxyURL to
// avoid the loopback-address exclusion in http.ProxyFromEnvironment (which
// would silently bypass any proxy for 127.0.0.1 targets) and the sync.Once
// caching that makes HTTPS_PROXY env-var changes within the same process
// unreliable. The structural test above confirms that the Proxy field is
// wired up; this test confirms the tunnelling itself works.
func TestBuildHTTPClientProxyTunnelsConnections(t *testing.T) {
Comment on lines +61 to +64
// Read the request line and headers.
buf := make([]byte, 4096)
n, err := conn.Read(buf)
if err != nil {
Comment on lines +121 to +125
out, err := exec.Command("docker", "network", "inspect", "kind",
"--format", "{{(index .IPAM.Config 0).Gateway}}").Output()
if err != nil {
return "", fmt.Errorf("failed to inspect kind docker network: %w", err)
}
Comment on lines +43 to +45
func (p *recordingProxy) port() string {
_, port, _ := net.SplitHostPort(p.addr())
return port
Comment on lines +187 to +193
patch := []map[string]interface{}{
{
"op": "replace",
"path": "/spec/template/spec/containers/0/env",
"value": envVars,
},
}
Comment thread test/e2e/steps/hooks.go
Comment on lines +30 to +36
// deploymentRestore records the original state of a deployment container so
// it can be rolled back after a test that modifies deployment configuration.
type deploymentRestore struct {
name string // deployment name
namespace string
containerName string
originalEnv []string // "NAME=VALUE" pairs
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.

2 participants