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
+3 -15
View File
@@ -9,12 +9,8 @@ import (
"github.com/golang-jwt/jwt/v5"
)
// The tests below deliberately stop short of AuthenticateToken's happy path:
// that branch needs a live *gorm.DB and the only driver in go.mod is postgres,
// so exercising it would mean a database in CI. Everything that runs before the
// row lookup (parsing, signature, claim extraction) is covered here, and the
// revocation rule itself is covered through tokenVersionOf, which is the whole
// of the comparison AuthenticateTokenWithClaims performs.
// Stops short of the row lookup (no DB in CI); revocation is covered via
// tokenVersionOf.
func testAuth() *Auth {
return InitAuth(&AuthConfig{
@@ -47,9 +43,6 @@ func TestTokenVersionOf(t *testing.T) {
}
}
// The comparison AuthenticateTokenWithClaims makes is tokenVersionOf(claim) vs
// tokenVersionOf(row). The table therefore encodes the revocation contract: an
// absent claim (0) must still match an un-bumped user, and any bump must not.
func TestTokenVersionMatch(t *testing.T) {
cases := []struct {
name string
@@ -104,9 +97,6 @@ func TestGenerateJWTTokenVersionClaim(t *testing.T) {
}
}
// The split of claims is load-bearing: admin lives in the access token so most
// requests need no row, and is absent from the refresh token so that revoking
// admin takes effect on the next refresh.
func TestGenerateJWTClaimSplit(t *testing.T) {
auth := testAuth()
tokens, err := auth.GenerateJWT(&models.User{ID: 7, Username: "adam", Admin: true, TokenVersion: 1})
@@ -191,9 +181,7 @@ func TestVerifyJWTRejections(t *testing.T) {
}
}
// A verified token with no usable id is a server-side inconsistency, not a
// client error, so it gets its own sentinel. Both cases below return before the
// row lookup, which is why a nil *gorm.DB is safe here.
// Both return before the row lookup, so a nil DB is safe.
func TestAuthenticateTokenInvalidClaims(t *testing.T) {
auth := testAuth()
cases := []struct {