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

Function Test_Ctx_Scheme_UntrustedProxyRange

ctx_test.go:5010–5035  ·  view source on GitHub ↗

go test -run Test_Ctx_Scheme_UntrustedProxyRange

(t *testing.T)

Source from the content-addressed store, hash-verified

5008
5009// go test -run Test_Ctx_Scheme_UntrustedProxyRange
5010func Test_Ctx_Scheme_UntrustedProxyRange(t *testing.T) {
5011 t.Parallel()
5012 app := New(Config{
5013 TrustProxy: true,
5014 TrustProxyConfig: TrustProxyConfig{Proxies: []string{"1.1.1.1/30"}},
5015 })
5016 c := app.AcquireCtx(&fasthttp.RequestCtx{})
5017
5018 c.Request().Header.Set(HeaderXForwardedProto, schemeHTTPS)
5019 require.Equal(t, schemeHTTP, c.Scheme())
5020 c.Request().Header.Reset()
5021
5022 c.Request().Header.Set(HeaderXForwardedProtocol, schemeHTTPS)
5023 require.Equal(t, schemeHTTP, c.Scheme())
5024 c.Request().Header.Reset()
5025
5026 c.Request().Header.Set(HeaderXForwardedSsl, "on")
5027 require.Equal(t, schemeHTTP, c.Scheme())
5028 c.Request().Header.Reset()
5029
5030 c.Request().Header.Set(HeaderXUrlScheme, schemeHTTPS)
5031 require.Equal(t, schemeHTTP, c.Scheme())
5032 c.Request().Header.Reset()
5033
5034 require.Equal(t, schemeHTTP, c.Scheme())
5035}
5036
5037// go test -run Test_Ctx_Scheme_UnTrustedProxy
5038func Test_Ctx_Scheme_UnTrustedProxy(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