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

Function Test_Ctx_Scheme_TrustedProxy

ctx_test.go:4957–4979  ·  view source on GitHub ↗

go test -run Test_Ctx_Scheme_TrustedProxy

(t *testing.T)

Source from the content-addressed store, hash-verified

4955
4956// go test -run Test_Ctx_Scheme_TrustedProxy
4957func Test_Ctx_Scheme_TrustedProxy(t *testing.T) {
4958 t.Parallel()
4959 app := New(Config{TrustProxy: true, TrustProxyConfig: TrustProxyConfig{Proxies: []string{"0.0.0.0"}}})
4960 c := app.AcquireCtx(&fasthttp.RequestCtx{})
4961
4962 c.Request().Header.Set(HeaderXForwardedProto, schemeHTTPS)
4963 require.Equal(t, schemeHTTPS, c.Scheme())
4964 c.Request().Header.Reset()
4965
4966 c.Request().Header.Set(HeaderXForwardedProtocol, schemeHTTPS)
4967 require.Equal(t, schemeHTTPS, c.Scheme())
4968 c.Request().Header.Reset()
4969
4970 c.Request().Header.Set(HeaderXForwardedSsl, "on")
4971 require.Equal(t, schemeHTTPS, c.Scheme())
4972 c.Request().Header.Reset()
4973
4974 c.Request().Header.Set(HeaderXUrlScheme, schemeHTTPS)
4975 require.Equal(t, schemeHTTPS, c.Scheme())
4976 c.Request().Header.Reset()
4977
4978 require.Equal(t, schemeHTTP, c.Scheme())
4979}
4980
4981// go test -run Test_Ctx_Scheme_TrustedProxyRange
4982func Test_Ctx_Scheme_TrustedProxyRange(t *testing.T) {

Callers

nothing calls this directly

Calls 6

AcquireCtxMethod · 0.80
NewFunction · 0.70
SetMethod · 0.65
RequestMethod · 0.65
SchemeMethod · 0.65
ResetMethod · 0.65

Tested by

no test coverage detected