mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-13 10:22:05 +00:00
fix: expire abandoned auth attempts
This commit is contained in:
@@ -109,3 +109,21 @@ func TestAuthCoordinatorRejectsExpiredCompletion(t *testing.T) {
|
||||
t.Fatalf("expired attempt completed: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuthCoordinatorExpiresAbandonedPendingAttemptsAtBoundary(t *testing.T) {
|
||||
now := time.Unix(1000, 0)
|
||||
coordinator := NewAuthCoordinator()
|
||||
ticket := SteamTicket{TicketID: "ticket-1", ExpiresAt: now.Add(time.Second)}
|
||||
if err := coordinator.Begin("attempt-1", ticket, now); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if expired := coordinator.Expire(now.Add(time.Second)); len(expired) != 1 || expired[0].State != AuthRejected {
|
||||
t.Fatalf("expired attempts = %+v", expired)
|
||||
}
|
||||
if _, err := coordinator.Get("attempt-1"); !errors.Is(err, ErrAuthAttemptPending) {
|
||||
t.Fatalf("expired attempt was exposed: %v", err)
|
||||
}
|
||||
if expired := coordinator.Expire(now.Add(2 * time.Second)); len(expired) != 0 {
|
||||
t.Fatalf("expired attempt repeated: %+v", expired)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user