Skip to content

test(agent): isolate anthropic oauth setup token from macos keychain - #58419

Closed
fyzanshaik wants to merge 1 commit into
NousResearch:mainfrom
fyzanshaik:anthropic-oauth-keychain-test-isolation
Closed

fyzanshaik wants to merge 1 commit into
NousResearch:mainfrom
fyzanshaik:anthropic-oauth-keychain-test-isolation

Conversation

@fyzanshaik

Copy link
Copy Markdown
Contributor

Fixes #58415

The setup-token tests mock subprocess.run to cover the claude setup-token subprocess. On macOS, credential resolution also shells out through subprocess.run to read Claude Code credentials from Keychain, so those tests were feeding the Claude CLI MagicMock into the Keychain JSON parser.

This keeps the setup-token seam focused by stubbing the Keychain credential reader to return None for the TestRunOauthSetupToken class. File credentials and env-var fallbacks remain exercised, but macOS Keychain subprocess behavior is tested independently.

Tests:

  • scripts/run_tests.sh tests/agent/test_anthropic_adapter.py

@alt-glitch alt-glitch added type/test Test coverage or test infrastructure comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint area/auth Authentication, OAuth, credential pools provider/anthropic Anthropic native Messages API P3 Low — cosmetic, nice to have labels Jul 4, 2026
@fyzanshaik
fyzanshaik force-pushed the anthropic-oauth-keychain-test-isolation branch from c156f12 to 77579b2 Compare July 8, 2026 12:44
@teknium1

Copy link
Copy Markdown
Collaborator

Thanks for the focused test-isolation fix. No blocking problems found.

run_oauth_setup_token() invokes subprocess.run() for claude setup-token at agent/anthropic_adapter.py:1350, then resolves credentials at agent/anthropic_adapter.py:1355. On Darwin, that resolution reaches the Keychain subprocess at agent/anthropic_adapter.py:872-911. Current TestRunOauthSetupToken mocks the same subprocess seam at tests/agent/test_anthropic_adapter.py:684-686, so the added class-local Keychain stub correctly keeps the mock scoped to the Claude CLI path while preserving file and environment fallback assertions. Dedicated Keychain coverage remains in tests/agent/test_anthropic_keychain.py:14-91.

This is an automated hermes-sweeper review.

@teknium1 teknium1 added the sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users label Jul 15, 2026
@teknium1

Copy link
Copy Markdown
Collaborator

Thanks @fyzanshaik — closing as resolved on main: the suite-wide autouse _neutralize_macos_keychain_creds guard from PR #74517 (via #35464) covers the anthropic oauth setup tests. Earliest credit on the keychain-mock class goes to #35093 (May 30). Verified post-merge (84/84 adapter tests green).

@teknium1 teknium1 closed this Jul 30, 2026
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/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have provider/anthropic Anthropic native Messages API sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users type/test Test coverage or test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Anthropic OAuth setup-token tests fail on macOS keychain subprocess path

3 participants