Skip to content

test(connectivity): isolate all checker env vars in TestDetectProxyConfig - #676

Merged
rrama merged 2 commits into
mainfrom
fix/proxy-config-test-env-isolation
Sep 15, 2026
Merged

rrama merged 2 commits into
mainfrom
fix/proxy-config-test-env-isolation

Conversation

@rrama

@rrama rrama commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Description

TestDetectProxyConfig cleared the environment before each subtest, but only the proxy variables:

proxyEnvVars := []string{"HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy", "NO_PROXY", "no_proxy"}

DetectProxyConfig iterates envVarSpecs, which also covers NODE_EXTRA_CA_CERTS, KRB5_CONFIG and KRB5CCNAME. Those three were never cleared, so the host machine's environment leaked into the result.

On any machine with NODE_EXTRA_CA_CERTS set — a corporate TLS-inspection CA bundle, for instance — six of the seven subtests fail:

Error: Not equal:
       expected: ""
       actual  : "/Users/…/zscaler-ca-bundle.pem"
Messages: NodeExtraCACerts mismatch

Unsetting the variable makes the same suite pass untouched, which is a confusing way to discover the test was never isolated. CI does not set these variables, which is why this has gone unnoticed.

The cleared list is now derived from envVarSpecs itself, so a variable added to the production spec is isolated automatically rather than quietly reintroducing this. It also removes the duplicated list of variable names.

Found while running the full suite to validate an unrelated change (#673).

Update after merging main: while this branch was open, main independently picked up the same isolation bug via an unrelated PR (#692) and fixed it too — with a hardcoded envVarsToClean list whose own comment flags it as needing manual sync with envVarSpecs. So the original failure this PR reported no longer reproduces on main. What this PR still adds: replacing that hardcoded, manually-synced list with the envVarSpecs-derived loop, so the sync-drift risk main's own comment calls out can't recur. Merged main in; the merge commit resolves the conflict between the two approaches by keeping this loop and main's newer "Node and Kerberos env vars set" test case.

Checklist

  • Tests added and all succeed (make test) — connectivity_check_extension/... passes with NODE_EXTRA_CA_CERTS still set in my shell, which reproduced the failure before this change
  • Regenerated mocks, etc. (make generate) — n/a
  • Linted (make lint) — 0 issues
  • Test your changes work for the CLI — n/a, test-only change; no shipped code or public API touched

Made with Cursor

…nfig

TestDetectProxyConfig cleared only the proxy variables (HTTPS_PROXY,
NO_PROXY and friends) before each case. DetectProxyConfig also reads
NODE_EXTRA_CA_CERTS, KRB5_CONFIG and KRB5CCNAME, so those leaked in from
the host environment.

Any developer with NODE_EXTRA_CA_CERTS set (a corporate TLS-inspection CA
bundle, for example) fails six of the seven subtests with a diff between
"" and their own certificate path. Unsetting the variable makes the same
suite pass, which is a confusing way to find out the test was never
isolated.

Derive the cleared list from envVarSpecs, the same list the production
code iterates, so variables added there are isolated automatically
instead of silently reintroducing this.

Co-authored-by: Cursor <cursoragent@cursor.com>
@snyk-io

snyk-io Bot commented Jul 30, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@snyk-io

snyk-io Bot commented Jul 30, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues
Secrets 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@rrama
rrama marked this pull request as ready for review August 3, 2026 10:08
@rrama
rrama requested review from a team as code owners August 3, 2026 10:08
@snyk-pr-review-bot

This comment has been minimized.

…y-config-test-env-isolation

Resolves a conflict in checker_test.go: main independently fixed the same
TestDetectProxyConfig env-var leak (PR #692) via a hardcoded envVarsToClean
list, flagged in its own comment as needing manual sync with envVarSpecs.
Kept this branch's derive-from-envVarSpecs loop instead, which removes that
sync-drift risk entirely, while preserving main's new "Node and Kerberos env
vars set" test case.
@snyk-pr-review-bot

Copy link
Copy Markdown

PR Reviewer Guide 🔍

🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected
📚 Repository Context Analyzed

This review considered 5 relevant code sections from 5 files (average relevance: 0.82)

🤖 Repository instructions applied (from AGENTS.md)

@rrama
rrama merged commit dadd77b into main Sep 15, 2026
15 checks passed
@rrama
rrama deleted the fix/proxy-config-test-env-isolation branch September 15, 2026 15:47
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