Trim comments to the non-obvious why
Test and deploy / test (push) Successful in 28s
Test and deploy / deploy (push) Successful in 31s

Drop narration, history and restated-code comments across the repo,
keep short ones for security boundaries, upstream quirks and ordering
constraints, and record the convention in CLAUDE.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-24 20:49:03 +00:00
co-authored by Claude Opus 5.5
parent effddd2794
commit 4530cb8dc4
222 changed files with 1173 additions and 5423 deletions
+4 -20
View File
@@ -10,20 +10,8 @@ import (
"github.com/gin-gonic/gin"
)
// Companion to auth_test.go, covering the two pure things it leaves out: the
// expiry the minting code bakes into each token, and the cookie attributes
// SetAuthCookies/ClearAuthCookies emit.
//
// DELIBERATELY NOT COVERED HERE:
// - AuthenticateToken past the id claim, and BumpTokenVersion: both need a
// live *gorm.DB and the only driver in go.mod is postgres.
// - Everything auth_test.go already covers (tokenVersionOf, the claim split,
// the VerifyJWT rejection table) — not duplicated.
// - Password hashing: there is none in this package; handlers own it.
//
// Cookie assertions go through a real gin context because gin, not this
// package, is what turns the SetCookie arguments into a header — asserting on
// the arguments alone would test nothing.
// Token expiry and cookie attributes. Cookies are checked through a real gin
// context, since gin builds the header.
// cookiesFrom runs fn against a throwaway gin context and returns what it set,
// keyed by cookie name.
@@ -40,9 +28,7 @@ func cookiesFrom(fn func(*gin.Context)) map[string]*http.Cookie {
return out
}
// exp must track the configured lifetime, because the cookie max-age is derived
// from the same number: if they disagreed the browser would hold a dead cookie
// or drop a live one.
// Cookie max-age is derived from the same lifetime.
func TestGenerateJWTExpiryMatchesConfiguredLifetime(t *testing.T) {
auth := testAuth()
issued := time.Now()
@@ -124,9 +110,7 @@ func TestSetAuthCookies(t *testing.T) {
}
}
// A browser only replaces a cookie when path, domain and flags match the
// original, so a deletion that differs in any of them silently leaves the user
// logged in. Hence asserting the attributes, not just the negative max-age.
// A deletion that differs in path, domain or flags silently fails.
func TestClearAuthCookiesMatchesTheCookiesItDeletes(t *testing.T) {
config := testAuth().Config
set := cookiesFrom(func(gc *gin.Context) {