test(19.7-05): framework unit tests for every validation row and the gate's admin stage

- pier: TestCatalog, TestDispatch, TestGuardRules, TestSessions (Redis
  across two instances and the memory store), TestFanOut; the store clock
  and stateless-server seams in export_test.go
- surf: TestStreamingRoute (throttle, CORS profile and access-log pattern on
  a stream route) and TestPierMount in both builds; the streaming smoke
  restores the mount hook it replaces
- wristband TestMCPScopes; cabana TestAccountContributions (Postgres part:
  transaction and unchanged My account payloads), TestRecordActionPrompt,
  TestScopeLimitForMethods; TestRecordActionPromptRun pins the empty Value
  of an action without a prompt
- vitest: 403 and failed-load cases for My account contributions, the
  cancelled prompt
- gate: every name required (tagged runs included), account.go unchanged
  since 51d088a, admin stage live
This commit is contained in:
Jakub Zych
2026-10-23 14:04:16 +02:00
parent 1111828e8a
commit f14eae96dd
18 changed files with 1696 additions and 10 deletions

View File

@@ -2,6 +2,7 @@ package pier
import (
"context"
"time"
"git.golem15.com/golem15/summercms/modules/backpack"
"git.golem15.com/golem15/summercms/modules/bouncer"
@@ -23,3 +24,25 @@ func (p *Pier) Resolve(ctx context.Context, raw string) (Identity, error) {
// Ceiling reports whether the read/write ceiling applies to the identity.
func (id Identity) Ceiling() bool { return id.ceiling }
// AdvanceStoreClock moves the memory session store's clock forward by d, so
// a test can expire idle sessions without waiting; a Redis store is moved
// with miniredis.FastForward instead.
func (p *Pier) AdvanceStoreClock(d time.Duration) bool {
ms, ok := p.store.(*memoryStore)
if !ok {
return false
}
ms.mu.Lock()
base := ms.now
ms.now = func() time.Time { return base().Add(d) }
ms.mu.Unlock()
return true
}
// StatelessServers counts the per-identity servers of the stateless path.
func (p *Pier) StatelessServers() int {
p.stateless.mu.Lock()
defer p.stateless.mu.Unlock()
return len(p.stateless.entries)
}