Skip to content

fix: isolate auth tests to prevent credential deletion#75

Merged
steve-calvert-glean merged 2 commits intomainfrom
scalvert/fix-test-auth-isolation
Apr 6, 2026
Merged

fix: isolate auth tests to prevent credential deletion#75
steve-calvert-glean merged 2 commits intomainfrom
scalvert/fix-test-auth-isolation

Conversation

@steve-calvert-glean
Copy link
Copy Markdown
Collaborator

Summary

  • TestAuthLogoutCmd_NoPanic and TestAuthStatusCmd_NoConfig were running against real system state with no mocks or temp dirs
  • The logout test called ClearConfig() which deleted ~/.glean/config.json and removed keyring entries, wiping real credentials on every test run
  • Both tests now use isolated temp dirs, swapped ConfigPath, and mocked keyring — matching the pattern from auth_persistence_test.go

Test plan

  • go test ./cmd/ -run "TestAuthLogoutCmd_NoPanic|TestAuthStatusCmd_NoConfig" -v passes
  • go test ./... -race passes
  • golangci-lint run clean

🤖 Generated with Claude Code

TestAuthLogoutCmd_NoPanic and TestAuthStatusCmd_NoConfig were running
against real system state — no mock, no temp dir. The logout test
called ClearConfig() which deleted ~/.glean/config.json and removed
keyring entries, wiping real credentials on every test run.

Isolate both tests with HOME set to a temp dir, ConfigPath swapped,
and keyring mocked — same pattern as auth_persistence_test.go.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@steve-calvert-glean steve-calvert-glean added bug Something isn't working labels Apr 6, 2026
Hoists isolateAuthState into internal/auth/authtest.IsolateAuthState
so both cmd/ and internal/auth/ tests use a single implementation.
Adds CLAUDE.md guidance requiring all auth-touching tests to use it.

Also fixes stale repo path references in CLAUDE.md after the repo
moved from ~/workspace/personal/ to ~/workspace/glean/.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@steve-calvert-glean steve-calvert-glean merged commit dc6846f into main Apr 6, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants