[scanner] 🐛 fix: resolve provider test SSRF blocking and CLI skip guards#19200
[scanner] 🐛 fix: resolve provider test SSRF blocking and CLI skip guards#19200clubanderson wants to merge 1 commit into
Conversation
Signed-off-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
🐝 Hi @clubanderson! I'm Trusted users — org members and contributors with write access — can mention Automation may take a moment to start, and follow-up happens through workflow activity rather than chat replies. |
|
👋 Hey @clubanderson — thanks for opening this PR!
This is an automated message. |
✅ Deploy Preview for kubestellarconsole canceled.
|
There was a problem hiding this comment.
Pull request overview
This PR aims to stabilize pkg/agent/providers tests by (1) allowing loopback httptest.NewServer targets to bypass the provider SSRF/private-IP guard during unit tests, and (2) skipping CLI-provider tests when the required CLI executables are not available in CI PATH.
Changes:
- Added shared test helpers to enable loopback SSRF bypass (
AllowLoopbackForTests) and to skip tests when a CLI executable is missing. - Updated Claude and Gemini HTTP-provider tests to enable loopback bypass before standing up
httptestservers. - Added executable-availability skip guards to CLI stderr-drain timeout tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
pkg/agent/providers/provider_test_helpers_test.go |
Adds test helpers for loopback SSRF bypass and PATH-based CLI skipping. |
pkg/agent/providers/provider_gemini_test.go |
Enables loopback bypass for Gemini provider tests using httptest.NewServer. |
pkg/agent/providers/provider_cli_timeout_test.go |
Skips CLI timeout tests when codex/gemini binaries aren’t present in PATH. |
pkg/agent/providers/provider_claude_test.go |
Enables loopback bypass for Claude provider tests using httptest.NewServer. |
| func allowLoopbackProviderHostsForTest(t *testing.T) { | ||
| t.Helper() | ||
|
|
||
| previous := AllowLoopbackForTests | ||
| AllowLoopbackForTests = true | ||
| t.Cleanup(func() { | ||
| AllowLoopbackForTests = previous | ||
| }) |
| func TestCodexProvider_StreamChatDrainsStderr(t *testing.T) { | ||
| skipIfExecutableMissing(t, "codex") | ||
|
|
||
| defer func() { ExecCommandContext = exec.CommandContext }() | ||
| ExecCommandContext = fakeProviderCLICommandContext |
|
Closing — superseded by #19214 (lint fixes) or no longer needed after build-gate unblock. |
Fixes provider test failures on main where SSRF protection blocks loopback httptest servers and CLI tools aren't in CI PATH.
Changes
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com