auth: review follow-ups + keyring-safe cli TestMain - #1360
Merged
Conversation
- CLAUDE.md: correct the `auth` command surface (login/logout/status/ contexts/use; drop the removed list/revoke) and document logout's --everywhere / --all-contexts flags. - logout: have runLogout take a single caller-selected revoke func instead of both revokeCurrent+revokeAll plus an `all` bool; the command already knows --everywhere. Drop the now-obsolete TestRunLogout_AllRevokesAllSessions (selection is covered end-to-end by TestLogoutCommand_FlagMatrix) and update the simple callers. - Fix stale method names in //nolint:wrapcheck comments left over from the Session -> AuthSession rename. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 7bbdd7fd89c1
The cli package's TestMain never routed go-keyring to its in-memory mock, unlike the auth subpackage. The default tokenstore backend is the real OS keychain, so any cli test that reaches a credential path without UseFileBackendForTesting — or runs in the window after such a test restores the global backend — would read the developer's real keychain and trigger a macOS unlock prompt during `mise run test:ci`. Call keyring.MockInit() once in TestMain so no cli test can touch the real keychain, mirroring cmd/entire/cli/auth's TestMain. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Entire-Checkpoint: eb9e9029effe
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request applies follow-up refinements to the auth/logout surface and hardens test isolation by ensuring the CLI package never hits the real OS keychain during unit tests.
Changes:
- Refactors
logoutinternals sorunLogouttakes a single caller-selected revoke function (current-session vs all-sessions selection remains in the Cobra command). - Updates
//nolint:wrapcheckcomments to matchAuthSession-renamed method names and removes an obsolete unit test now covered by the command flag-matrix test. - Adds
keyring.MockInit()to theclipackageTestMainto prevent any tests from accessing the developer’s real keychain.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| cmd/entire/cli/logout.go | Simplifies logout’s revocation injection and refreshes wrapcheck annotations. |
| cmd/entire/cli/logout_test.go | Updates unit tests for the new runLogout signature and removes a redundant test. |
| cmd/entire/cli/global_test.go | Mocks go-keyring globally for the cli package test suite to avoid OS keychain access. |
| cmd/entire/cli/auth.go | Fixes stale wrapcheck comment text after method renames. |
| CLAUDE.md | Updates documented auth command surface and logout flags to match current behavior. |
nodo
previously approved these changes
Jun 4, 2026
The single revoke func runLogout takes can now represent either the current session or every session on the core (--everywhere), so the old "Current" name was misleading. Rename to boundRevokeFunc and note the current-or-all semantics — it contrasts with the unbound revokeTargetFunc (coreURL + token still open) used by the --all-contexts sweep. Addresses PR #1360 review feedback. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 1e0358381bae
toothbrush
approved these changes
Jun 4, 2026
toothbrush
left a comment
Contributor
There was a problem hiding this comment.
Ah, thanks for the cleanup 🫡
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.
https://entire.io/gh/entireio/cli/trails/511
Follow-ups from review of the (now-merged) auth-context-consolidation work, plus a test-isolation fix.
Changes
auth: review follow-ups(3eeb08c)authcommand surface —login/logout/status/contexts/use(drop the removedlist/revoke) and documentlogout's--everywhere/--all-contextsflags.runLogoutnow takes a single caller-selected revoke func instead of bothrevokeCurrent+revokeAllplus anallbool — the command already knows--everywhere. Dropped the now-obsoleteTestRunLogout_AllRevokesAllSessions(selection is covered end-to-end byTestLogoutCommand_FlagMatrix) and updated the simple callers.//nolint:wrapcheckcomments left over from theSession→AuthSessionrename.test: mock the OS keyring in the cli package TestMain(1ea54e2)clipackage'sTestMainnever routed go-keyring to its in-memory mock (unlike theauthsubpackage). The default tokenstore backend is the real OS keychain, so aclitest reaching a credential path withoutUseFileBackendForTesting— or running in the window after such a test restores the global backend — could read the developer's real keychain and trigger a macOS unlock prompt duringmise run test:ci.keyring.MockInit()once inTestMain, mirroringcmd/entire/cli/auth'sTestMain, so noclitest can touch the real keychain. This closes a latent, pre-existing gap (not introduced by the auth branch).Testing
go build ./..., targetedclitests passmise run fmt+mise run lint— 0 issues🤖 Generated with Claude Code
Note
Low Risk
Local CLI auth/logout and test isolation only; behavior for
--everywhereis unchanged and still covered by the flag-matrix e2e test.Overview
Docs:
CLAUDE.mdnow documents the consolidatedauthsurface (contexts,use; nolist/revoke) andlogout’s--everywhere/--all-contextsflags.Logout refactor:
runLogouttakes one caller-chosenrevokefunc instead ofrevokeCurrent+revokeAlland anallbool—the Cobra handler already selects current vs all sessions via--everywhere. Unit tests were updated;TestRunLogout_AllRevokesAllSessionswas removed in favor ofTestLogoutCommand_FlagMatrix.Tests:
clipackageTestMaincallskeyring.MockInit()so tests never touch the real OS keychain (avoids macOS unlock prompts). Stale//nolint:wrapcheckcomments were aligned withAuthSessionnaming.Reviewed by Cursor Bugbot for commit 1ea54e2. Configure here.