server auth
This commit is contained in:
19
apps/server/internal/httpserver/rate_limit_test.go
Normal file
19
apps/server/internal/httpserver/rate_limit_test.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package httpserver
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestRateLimiterRejectsAfterLimit(t *testing.T) {
|
||||
limiter := newRateLimiter(2, time.Minute)
|
||||
if !limiter.Allow("ip:path") {
|
||||
t.Fatal("first attempt should be allowed")
|
||||
}
|
||||
if !limiter.Allow("ip:path") {
|
||||
t.Fatal("second attempt should be allowed")
|
||||
}
|
||||
if limiter.Allow("ip:path") {
|
||||
t.Fatal("third attempt should be rate limited")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user