Skip to content

test(auth): align copilot-remove test with borrowed-credential policy (#31416)#31946

Merged
teknium1 merged 1 commit into
mainfrom
fix/auth-remove-copilot-test-borrowed-source
May 25, 2026
Merged

test(auth): align copilot-remove test with borrowed-credential policy (#31416)#31946
teknium1 merged 1 commit into
mainfrom
fix/auth-remove-copilot-test-borrowed-source

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

tests/hermes_cli/test_auth_commands.py::test_auth_remove_copilot_suppresses_all_variants now passes on current main. Pre-existing failure introduced by PR #31416 (avoid persisting borrowed credential secrets, merged May 25 2026).

Root cause

PR #31416 added sanitize_borrowed_credential_payload() to agent/credential_pool.py. The new policy: any (provider, source) tuple NOT in _PERSISTABLE_PROVIDER_SOURCES is "borrowed" and gets its access_token stripped at the disk boundary. (copilot, gh_cli) is correctly classified as borrowed — gh auth token is the canonical source of truth, not auth.json.

The test fixture pre-seeded an access_token directly into a copilot/gh_cli pool entry and expected load_pool to surface it. Under the new policy that token gets stripped, pool.entries() returns empty, and resolve_target("1") correctly says "No credential #1."

The behavior under test (suppression of gh_cli + all env:* variants on remove) is unchanged. Only the fixture's seeding mechanism needs updating to match the new contract.

Changes

  • tests/hermes_cli/test_auth_commands.pytest_auth_remove_copilot_suppresses_all_variants now seeds the pool via mocked resolve_copilot_token() / get_copilot_api_token() (the actual runtime hydration path), matching production behavior.

Validation

Before After
test_auth_remove_copilot_suppresses_all_variants FAIL (SystemExit: No credential #1) PASS
Rest of test_auth_commands.py 45 pass 46 pass
Behavior under test (suppression contract) unchanged unchanged

Reproduced the failure on stock origin/main HEAD with no other patches applied. CI run from PR #31929 surfaced it.

Why fix-it-first PR

Per references/green-ci-policy.md: when a pre-existing failure blocks an unrelated PR, the right move is a separate fix-it PR. This test failure was blocking my /resume bracket-stripping salvage (#31929); landing this first lets that PR rebase onto a clean main.

Infographic

auth-test-realignment

https://v3b.fal.media/files/b/0a9b99e7/UbnXaIc3cO0K5-hC7YINq_CtkbmY2r.png

…#31416)

PR #31416 (avoid persisting borrowed credential secrets) added
sanitize_borrowed_credential_payload, which strips access_token from
any auth.json pool entry whose (provider, source) isn't in the
_PERSISTABLE_PROVIDER_SOURCES allowlist.

(copilot, gh_cli) is borrowed (not in the allowlist), so the test
fixture's pre-seeded access_token now gets stripped at load_pool()
time, leaving the pool empty. resolve_target('1') then fails with
'No credential #1. Provider: copilot.'

Fix: align the test with the new contract. At runtime, copilot tokens
are hydrated by resolve_copilot_token() — mock that path so the pool
gets an entry the test can remove. The behavior under test
(suppression of gh_cli + env variants on remove) is unchanged.

CI repro on origin/main HEAD; reproduced locally with stock checkout.
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: fix/auth-remove-copilot-test-borrowed-source vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9123 on HEAD, 9123 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4869 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/test Test coverage or test infrastructure P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard area/auth Authentication, OAuth, credential pools labels May 25, 2026
@teknium1 teknium1 merged commit 920b350 into main May 25, 2026
32 of 34 checks passed
@teknium1 teknium1 deleted the fix/auth-remove-copilot-test-borrowed-source branch May 25, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have type/test Test coverage or test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants