优化结构
This commit is contained in:
parent
9dd62c9fb6
commit
ca52de5db0
|
|
@ -0,0 +1,22 @@
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue