go test -run Test_Ctx_Host_UntrustedProxy
(t *testing.T)
| 2849 | |
| 2850 | // go test -run Test_Ctx_Host_UntrustedProxy |
| 2851 | func Test_Ctx_Host_UntrustedProxy(t *testing.T) { |
| 2852 | t.Parallel() |
| 2853 | // Don't trust any proxy |
| 2854 | { |
| 2855 | app := New(Config{TrustProxy: true, TrustProxyConfig: TrustProxyConfig{Proxies: []string{}}}) |
| 2856 | c := app.AcquireCtx(&fasthttp.RequestCtx{}) |
| 2857 | c.Request().SetRequestURI("http://google.com/test") |
| 2858 | c.Request().Header.Set(HeaderXForwardedHost, "google1.com") |
| 2859 | require.Equal(t, "google.com", c.Host()) |
| 2860 | app.ReleaseCtx(c) |
| 2861 | } |
| 2862 | // Trust to specific proxy list |
| 2863 | { |
| 2864 | app := New(Config{TrustProxy: true, TrustProxyConfig: TrustProxyConfig{Proxies: []string{"0.8.0.0", "0.8.0.1"}}}) |
| 2865 | c := app.AcquireCtx(&fasthttp.RequestCtx{}) |
| 2866 | c.Request().SetRequestURI("http://google.com/test") |
| 2867 | c.Request().Header.Set(HeaderXForwardedHost, "google1.com") |
| 2868 | require.Equal(t, "google.com", c.Host()) |
| 2869 | app.ReleaseCtx(c) |
| 2870 | } |
| 2871 | } |
| 2872 | |
| 2873 | // go test -run Test_Ctx_Host_TrustedProxy |
| 2874 | func Test_Ctx_Host_TrustedProxy(t *testing.T) { |
nothing calls this directly
no test coverage detected