Skip to content

test(#5569): make runAgent fixture tests hermetic against ambient credentials - #6014

Open
fullsend-ai-coder[bot] wants to merge 1 commit into
mainfrom
agent/5569-hermetic-runagent-tests
Open

test(#5569): make runAgent fixture tests hermetic against ambient credentials#6014
fullsend-ai-coder[bot] wants to merge 1 commit into
mainfrom
agent/5569-hermetic-runagent-tests

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

Summary

  • Add neutralizeAgentsRepoFallback() test helper that isolates fixture-based runAgent tests from ambient GitHub credentials ($GH_TOKEN, $GITHUB_TOKEN, gh auth token via keyring) and the public agents-repo fallback (fullsend-ai/agents).
  • Call the helper from useFakeOpenshell() and useFakeOpenshellProviders(), which are already used by every runAgent test — so all 27+ fixture-based tests are now hermetic with zero individual test changes.

Context

Tests pass in CI only because lint.yml blanks GH_TOKEN/GITHUB_TOKEN and the runner lacks gh auth login state. On developer machines (or any CI job without those blanking steps), resolveToken() succeeds, tryAgentsRepoFallback fetches the live harness from fullsend-ai/agents@v0 over the network, and tests silently exercise a different code path than their fixtures specify.

The helper neutralizes this at three layers:

  1. Env varst.Setenv("GH_TOKEN", "") / t.Setenv("GITHUB_TOKEN", "")
  2. Keyringt.Setenv("GH_CONFIG_DIR", t.TempDir()) (empty dir → gh auth token fails)
  3. NetworkdefaultAgentsRepoURLPrefix overridden to a non-routable address so even unauthenticated requests to the public repo fail fast

Testing

  • All 27+ runAgent tests pass with the helper active
  • TryAgentsRepoFallback tests (which manage the URL prefix themselves) remain unaffected
  • Pre-existing failure in TestPostScriptEnv_NoSchemaAppendedWhenNoValidationLoop is unrelated

Closes #5569

Post-script verification

  • Branch is not main/master (agent/5569-hermetic-runagent-tests)
  • Secret scan passed (gitleaks — 19b3583154c39bed631455ca9e219dc512a16005..HEAD)
  • PR body secret scan passed (gitleaks — no-git)

…dentials

Tests in internal/cli/run_test.go that call runAgent(ctx, "code", dir, ...)
were not hermetic: when GH_TOKEN, GITHUB_TOKEN, or `gh auth token` (via
the keyring) resolves a token, resolveAgentSource → tryAgentsRepoFallback
silently fetches the live harness from fullsend-ai/agents instead of
using the test's local fixture. Even without credentials, the
unauthenticated forge client can reach the public agents repo.

Add neutralizeAgentsRepoFallback() helper that:
- Blanks GH_TOKEN and GITHUB_TOKEN via t.Setenv
- Points GH_CONFIG_DIR to an empty temp dir (neutralizes gh auth token)
- Overrides defaultAgentsRepoURLPrefix to a non-routable address

Call the helper from useFakeOpenshell() and useFakeOpenshellProviders(),
which are used by every runAgent test, ensuring all fixture-based tests
exercise only their local harness regardless of the developer's
environment.

Closes #5569
@fullsend-ai-coder
fullsend-ai-coder Bot requested a review from a team as a code owner August 7, 2026 22:20
@fullsend-ai-coder fullsend-ai-coder Bot added the ready-for-review Agent PR ready for human review label Aug 7, 2026
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Agent PR ready for human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

internal/cli tests using runAgent("code", fixtureDir) aren't hermetic — live agents-repo fetch can bypass local fixture

1 participant