initial commit

This commit is contained in:
Daniel Noulet 2026-10-01 23:15:57 +02:00
commit 54576d9d33
61 changed files with 5569 additions and 0 deletions

View file

@ -0,0 +1,24 @@
package server
import (
"testing"
"time"
)
func TestLoginGuardLocksAfterFiveFailures(t *testing.T) {
guard := newLoginGuard()
now := time.Now()
for range 5 {
if !guard.allowed("address|user@example.com", now) {
t.Fatal("guard locked too early")
}
guard.fail("address|user@example.com", now)
}
if guard.allowed("address|user@example.com", now) {
t.Fatal("guard did not lock after five failures")
}
guard.success("address|user@example.com")
if !guard.allowed("address|user@example.com", now) {
t.Fatal("successful login did not clear failures")
}
}