test(#5569): make runAgent fixture tests hermetic against ambient credentials - #6014
Open
fullsend-ai-coder[bot] wants to merge 1 commit into
Open
test(#5569): make runAgent fixture tests hermetic against ambient credentials#6014fullsend-ai-coder[bot] wants to merge 1 commit into
fullsend-ai-coder[bot] wants to merge 1 commit into
Conversation
…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
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Summary
neutralizeAgentsRepoFallback()test helper that isolates fixture-basedrunAgenttests from ambient GitHub credentials ($GH_TOKEN,$GITHUB_TOKEN,gh auth tokenvia keyring) and the public agents-repo fallback (fullsend-ai/agents).useFakeOpenshell()anduseFakeOpenshellProviders(), which are already used by everyrunAgenttest — so all 27+ fixture-based tests are now hermetic with zero individual test changes.Context
Tests pass in CI only because
lint.ymlblanksGH_TOKEN/GITHUB_TOKENand the runner lacksgh auth loginstate. On developer machines (or any CI job without those blanking steps),resolveToken()succeeds,tryAgentsRepoFallbackfetches the live harness fromfullsend-ai/agents@v0over the network, and tests silently exercise a different code path than their fixtures specify.The helper neutralizes this at three layers:
t.Setenv("GH_TOKEN", "")/t.Setenv("GITHUB_TOKEN", "")t.Setenv("GH_CONFIG_DIR", t.TempDir())(empty dir →gh auth tokenfails)defaultAgentsRepoURLPrefixoverridden to a non-routable address so even unauthenticated requests to the public repo fail fastTesting
runAgenttests pass with the helper activeTryAgentsRepoFallbacktests (which manage the URL prefix themselves) remain unaffectedTestPostScriptEnv_NoSchemaAppendedWhenNoValidationLoopis unrelatedCloses #5569
Post-script verification
agent/5569-hermetic-runagent-tests)19b3583154c39bed631455ca9e219dc512a16005..HEAD)