test(ui): avoid a literal em dash in the em dash check

- test(ui): avoid a literal em dash in the em dash check
- fix(cli): accept any positive int64 audit count and share the last active admin rule
- fix(api): limit audit before_id to 2^53-1
- fix(api): audit unmatched api requests, bound every request body and record audit write failures
- fix(ui): recheck the account in the login transaction and require existing zones on zone pages
- fix(api): recheck the acting admin and the stored password hash in change transactions
- fix(db): keep committed outcomes on lock release failure, narrow the records contract and trace sql statements
- fix(db): make the initial migration restartable and verify the application schema
- fix(auth): never move last_seen_at backwards on concurrent session touches
- test(api): cover lock release failure after commit and handler tracing without secrets
- fix(test): redact credentials from mysql setup errors
- fix(audit): retain addressed objects on admin refusals
- test(db): cover migration restarts and records contract ranges in mysql
- test(api): verify account races and audit rollback in mysql
- fix(auth): reject password changes after account deletion
- docs: document unknown api audit entries
- fix(audit): bound failure retries and redact sensitive sql parameters
- fix(test): isolate docker resources and cover image cli commands
- test(auth): expect unauthorized after an account deletion race
- fix(db): verify application column widths and foreign keys
This commit is contained in:
bryanpedini committed 2026-11-19 15:46:12 +01:00
1 parent 5f17aab6ca
commit 53444bec7a
40 files changed
+2332 -254

No files matched your search

+42
View File
@@ -9,6 +9,8 @@ import (
"context"
"database/sql"
"errors"
"slices"
"sync"
"testing"
"time"
)
@@ -274,6 +276,46 @@ func TestIntegrationSessionStore(t *testing.T) {
if !got.Session.LastSeenAt.Equal(base.Add(time.Minute)) {
t.Fatal(got.Session.LastSeenAt)
}
for _, stale := range []time.Time{base.Add(90 * time.Second), base.Add(time.Minute - time.Microsecond), base} {
if err := s.TouchSession(ctx, hash(1), stale); err != nil {
t.Fatal(err)
}
if got, _ = s.SessionByTokenHash(ctx, hash(1)); !got.Session.LastSeenAt.Equal(base.Add(time.Minute)) {
t.Fatalf("touch at %v moved last_seen_at to %v", stale, got.Session.LastSeenAt)
}
}
touches := make([]time.Time, 16)
for i := range touches {
touches[i] = base.Add(2*time.Minute + time.Duration(i)*time.Second)
}
var wg sync.WaitGroup
for _, at := range touches {
wg.Go(func() {
if err := s.TouchSession(ctx, hash(1), at); err != nil {
t.Error(err)
}
})
}
wg.Wait()
got, _ = s.SessionByTokenHash(ctx, hash(1))
first := got.Session.LastSeenAt
if !slices.ContainsFunc(touches, first.Equal) {
t.Fatalf("concurrent touches left %v", first)
}
for _, at := range touches {
if err := s.TouchSession(ctx, hash(1), at); err != nil {
t.Fatal(err)
}
}
if got, _ = s.SessionByTokenHash(ctx, hash(1)); !got.Session.LastSeenAt.Equal(first) {
t.Fatalf("an older concurrent touch moved last_seen_at from %v to %v", first, got.Session.LastSeenAt)
}
if err := s.TouchSession(ctx, hash(1), first.Add(time.Minute)); err != nil {
t.Fatal(err)
}
if got, _ = s.SessionByTokenHash(ctx, hash(1)); !got.Session.LastSeenAt.Equal(first.Add(time.Minute)) {
t.Fatal("due touch not written")
}
if ok, err := s.DeleteSession(ctx, hash(2)); !ok || err != nil {
t.Fatal(ok, err)
}