initial commit
This commit is contained in:
commit
54576d9d33
61 changed files with 5569 additions and 0 deletions
24
internal/server/passwordauth_test.go
Normal file
24
internal/server/passwordauth_test.go
Normal 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")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue