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

Function Test_Ctx_Host_TrustedProxyRange

ctx_test.go:2939–2948  ·  view source on GitHub ↗

go test -run Test_Ctx_Host_TrustedProxyRange

(t *testing.T)

Source from the content-addressed store, hash-verified

2937
2938// go test -run Test_Ctx_Host_TrustedProxyRange
2939func Test_Ctx_Host_TrustedProxyRange(t *testing.T) {
2940 t.Parallel()
2941
2942 app := New(Config{TrustProxy: true, TrustProxyConfig: TrustProxyConfig{Proxies: []string{"0.0.0.0/30"}}})
2943 c := app.AcquireCtx(&fasthttp.RequestCtx{})
2944 c.Request().SetRequestURI("http://google.com/test")
2945 c.Request().Header.Set(HeaderXForwardedHost, "google1.com")
2946 require.Equal(t, "google1.com", c.Host())
2947 app.ReleaseCtx(c)
2948}
2949
2950// go test -run Test_Ctx_Host_UntrustedProxyRange
2951func Test_Ctx_Host_UntrustedProxyRange(t *testing.T) {

Callers

nothing calls this directly

Calls 6

AcquireCtxMethod · 0.80
ReleaseCtxMethod · 0.80
NewFunction · 0.70
RequestMethod · 0.65
SetMethod · 0.65
HostMethod · 0.65

Tested by

no test coverage detected