From e540fcfeb6e17224a6916b345b66d4b058688e6c Mon Sep 17 00:00:00 2001 From: Notealot <714804968@qq.com> Date: Mon, 25 Oct 2021 22:31:30 +0800 Subject: [PATCH] refactor for unit tests --- context_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/context_test.go b/context_test.go index c286c0f4..97b05e3d 100644 --- a/context_test.go +++ b/context_test.go @@ -12,6 +12,7 @@ import ( "html/template" "io" "mime/multipart" + "net" "net/http" "net/http/httptest" "os" @@ -2051,7 +2052,8 @@ func TestRemoteIPFail(t *testing.T) { c, _ := CreateTestContext(httptest.NewRecorder()) c.Request, _ = http.NewRequest("POST", "/", nil) c.Request.RemoteAddr = "[:::]:80" - ip, trust := c.RemoteIP() + ip := net.ParseIP(c.RemoteIP()) + trust := c.engine.isTrustedProxy(ip) assert.Nil(t, ip) assert.False(t, trust) }