(t *testing.T, srv *httptest.Server, serveTLS bool, toTLS bool)
| 961 | } |
| 962 | |
| 963 | func createSimpleProxyServer(t *testing.T, srv *httptest.Server, serveTLS bool, toTLS bool) *httptest.Server { |
| 964 | e := echo.New() |
| 965 | |
| 966 | if toTLS { |
| 967 | // proxy to tls target |
| 968 | tgtURL, _ := url.Parse(srv.URL) |
| 969 | tgtURL.Scheme = "wss" |
| 970 | balancer := NewRandomBalancer([]*ProxyTarget{{URL: tgtURL}}) |
| 971 | |
| 972 | defaultTransport, ok := http.DefaultTransport.(*http.Transport) |
| 973 | if !ok { |
| 974 | t.Fatal("Default transport is not of type *http.Transport") |
| 975 | } |
| 976 | transport := defaultTransport.Clone() |
| 977 | transport.TLSClientConfig = &tls.Config{ |
| 978 | InsecureSkipVerify: true, |
| 979 | } |
| 980 | e.Use(ProxyWithConfig(ProxyConfig{Balancer: balancer, Transport: transport})) |
| 981 | } else { |
| 982 | // proxy to non-TLS target |
| 983 | tgtURL, _ := url.Parse(srv.URL) |
| 984 | balancer := NewRandomBalancer([]*ProxyTarget{{URL: tgtURL}}) |
| 985 | e.Use(ProxyWithConfig(ProxyConfig{Balancer: balancer})) |
| 986 | } |
| 987 | |
| 988 | if serveTLS { |
| 989 | // serve proxy server with TLS |
| 990 | ts := httptest.NewTLSServer(e) |
| 991 | return ts |
| 992 | } |
| 993 | // serve proxy server without TLS |
| 994 | ts := httptest.NewServer(e) |
| 995 | return ts |
| 996 | } |
| 997 | |
| 998 | // TestProxyWithConfigWebSocketNonTLS2NonTLS tests the proxy with non-TLS to non-TLS WebSocket connection. |
| 999 | func TestProxyWithConfigWebSocketNonTLS2NonTLS(t *testing.T) { |
no test coverage detected
searching dependent graphs…