MCPcopy
hub / github.com/gofiber/fiber / Test_Ctx_IP_TrustedProxy

Function Test_Ctx_IP_TrustedProxy

ctx_test.go:3387–3397  ·  view source on GitHub ↗

go test -run Test_Ctx_IP_TrustedProxy

(t *testing.T)

Source from the content-addressed store, hash-verified

3385
3386// go test -run Test_Ctx_IP_TrustedProxy
3387func Test_Ctx_IP_TrustedProxy(t *testing.T) {
3388 t.Parallel()
3389 app := New(Config{
3390 TrustProxy: true,
3391 TrustProxyConfig: TrustProxyConfig{Proxies: []string{"0.0.0.0"}},
3392 ProxyHeader: HeaderXForwardedFor,
3393 })
3394 c := app.AcquireCtx(&fasthttp.RequestCtx{})
3395 c.Request().Header.Set(HeaderXForwardedFor, "0.0.0.1")
3396 require.Equal(t, "0.0.0.1", c.IP())
3397}
3398
3399// go test -run Test_Ctx_IP_StripTrustedProxies
3400func Test_Ctx_IP_StripTrustedProxies(t *testing.T) {

Callers

nothing calls this directly

Calls 5

AcquireCtxMethod · 0.80
NewFunction · 0.70
SetMethod · 0.65
RequestMethod · 0.65
IPMethod · 0.65

Tested by

no test coverage detected