kra-new/internal/server/middleware/rate_limit_nil_test.go

23 lines
601 B
Go

package middleware
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/gin-gonic/gin"
)
func TestSecurityRateLimitAllowsRequestsWhenSecurityServiceIsUnset(t *testing.T) {
gin.SetMode(gin.TestMode)
engine := gin.New()
engine.Use(SecurityRateLimit(nil))
engine.POST("/base/login", func(c *gin.Context) { c.Status(http.StatusNoContent) })
response := httptest.NewRecorder()
engine.ServeHTTP(response, httptest.NewRequest(http.MethodPost, "/base/login", nil))
if response.Code != http.StatusNoContent {
t.Fatalf("status = %d, want %d", response.Code, http.StatusNoContent)
}
}