test(client): stop the suite writing to the developer's real Keychain - #88
Conversation
Running `go test ./...` on a Mac left OAuth entries in the developer's login Keychain. Several client tests drive the full authentication path, and a successful authentication caches the issued token through tokencache.Save. Those tests never swapped the keyring openers, so Save reached defaultOpenKeyring, which on a cgo-enabled build is the real Keychain. Entries for identities like test@example.com accumulated there and stayed. They also do not clean themselves up: released binaries are built with CGO_ENABLED=0 and the pinned keyring registers its Keychain backend under a "darwin && cgo" constraint, so an installed eightctl cannot see those items and `eightctl logout` never removes them. They have to be deleted by hand with security(1). Fixed at the package level rather than per test. A TestMain points both openers at in-memory stores for the whole package, so every current test and any later one that reaches the cache is covered without having to remember this. Reproduced and verified on darwin/arm64, cgo enabled: security delete-generic-password -s eightctl # start clean go test -count=1 ./internal/client/ security find-generic-password -s eightctl # before: an item; after: none -count=1 matters: a cached test result does not run the test and does not write. Removing the TestMain reproduces the pollution, so the guard is what prevents it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CtVNrHHZRwkbZhk34UxLi8
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 11, 2026, 8:15 PM ET / September 12, 2026, 00:15 UTC (Revision 2). ClawSweeper reviewWhat this changesRedirects client authentication tests to in-memory credential stores and clarifies how macOS builds choose token storage. Merge readiness✅ Ready for maintainer review The fix remains necessary on current main, and no actionable defect was found. Maintainer verification directly covers the credential-store isolation; this PR is ready for ordinary merge review. Priority: P2 Review scores
Verification
How this fits togetherEightctl’s client authenticates with Eight Sleep and caches tokens for subsequent commands. Its authentication tests exercise that same cache path; the new test entrypoint substitutes memory-backed stores before the tests run. flowchart TD
A[Client test suite] --> B[Install test credential stores]
B --> C[Authentication tests]
C --> D[Client token cache]
D --> E[Primary memory store]
D --> F[Fallback memory store]
Before mergeNone. Agent review detailsSecurityNone. Review metricsNone. Technical reviewBest possible solution: Keep credential-store substitution at the client test boundary while preserving the production cache and its separate backend tests. Do we have a high-confidence way to reproduce the issue? Yes. Current source connects the authentication test to persistent cache openers, and the owner reports a guarded before/after compiled-test reproduction on macOS; this read-only review did not execute tests. Is this the best way to solve the issue? Yes. Reusing both existing opener hooks in TestMain covers the package without altering production storage or duplicating backend implementation. AGENTS.md: not found in the target repository. Codex review notes: model internal, reasoning medium; reviewed against db84b936e0ba. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Maintainer verification completed on head
The added README correction documents the existing CGO distinction; it does not change token-storage policy. Thanks @omarshahine for the fix. Prepared for squash merge; the final dependency/notes PR carries the changelog entry. |
Refresh jose2go, go-runewidth, Ultraviolet, Go support modules, gofumpt, and pnpm while retaining Go 1.26.7 and Node.js 24 as supported minimums. Collect the complete Unreleased notes, including #88. Verified with both supported Go versions, built CLI smoke, real file-cache integration, grapheme wrapping, frozen lockfile installation, release-artifact checks, green CI, and clean independent review.
Client authentication tests currently write synthetic OAuth tokens to the developer's persistent credential stores. On CGO-enabled macOS builds, those entries reach Keychain and remain after the test process exits.
Install in-memory primary and fallback stores in the client package's
TestMain, covering every test that reaches authentication. Production authentication and storage behavior stay unchanged. The README also clarifies the existing build distinction: published macOS binaries disable CGO and use the file cache, while CGO-enabled source builds prefer Keychain.Verification:
TestMainreaches a persistent opener and fails; the same authentication test passes withTestMain. Guards stop access before opening any real credential store.--versionand--help; formatting and golangci-lint pass.Contributor: @omarshahine. The changelog entry is carried by the final dependency/notes PR to keep sibling branches independent.