From 2e72edbd6409d5e5f26fe82ecfca2917e9c649ef Mon Sep 17 00:00:00 2001 From: starsz Date: Thu, 29 Apr 2021 09:29:06 +0800 Subject: [PATCH] update: test ip --- api/internal/filter/ip_filter_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/internal/filter/ip_filter_test.go b/api/internal/filter/ip_filter_test.go index 608e68c7b5..dad4da6871 100644 --- a/api/internal/filter/ip_filter_test.go +++ b/api/internal/filter/ip_filter_test.go @@ -58,19 +58,19 @@ func TestIPFilter_Handle(t *testing.T) { assert.Equal(t, 200, w.Code) // should forbidden - conf.AllowList = []string{"8.8.8.8"} + conf.AllowList = []string{"127.0.0.1"} r = gin.New() r.Use(IPFilter()) r.GET("/test", func(c *gin.Context) {}) req := httptest.NewRequest("GET", "/test", nil) - req.Header.Set("X-Forwarded-For", "8.8.8.8") + req.Header.Set("X-Forwarded-For", "127.0.0.1") w = httptest.NewRecorder() r.ServeHTTP(w, req) assert.Equal(t, 403, w.Code) req = httptest.NewRequest("GET", "/test", nil) - req.Header.Set("X-Real-Ip", "8.8.8.8") + req.Header.Set("X-Real-Ip", "127.0.0.1") w = httptest.NewRecorder() r.ServeHTTP(w, req) assert.Equal(t, 403, w.Code)