MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / TestBuildHTTPTransportHTTPProxy

Function TestBuildHTTPTransportHTTPProxy

sdk/proxyutil/proxy_test.go:81–118  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

79}
80
81func TestBuildHTTPTransportHTTPProxy(t *testing.T) {
82 t.Parallel()
83
84 transport, mode, errBuild := BuildHTTPTransport("http://proxy.example.com:8080")
85 if errBuild != nil {
86 t.Fatalf("BuildHTTPTransport returned error: %v", errBuild)
87 }
88 if mode != ModeProxy {
89 t.Fatalf("mode = %d, want %d", mode, ModeProxy)
90 }
91 if transport == nil {
92 t.Fatal("expected transport, got nil")
93 }
94
95 req, errRequest := http.NewRequest(http.MethodGet, "https://example.com", nil)
96 if errRequest != nil {
97 t.Fatalf("http.NewRequest returned error: %v", errRequest)
98 }
99
100 proxyURL, errProxy := transport.Proxy(req)
101 if errProxy != nil {
102 t.Fatalf("transport.Proxy returned error: %v", errProxy)
103 }
104 if proxyURL == nil || proxyURL.String() != "http://proxy.example.com:8080" {
105 t.Fatalf("proxy URL = %v, want http://proxy.example.com:8080", proxyURL)
106 }
107
108 defaultTransport := mustDefaultTransport(t)
109 if transport.ForceAttemptHTTP2 != defaultTransport.ForceAttemptHTTP2 {
110 t.Fatalf("ForceAttemptHTTP2 = %v, want %v", transport.ForceAttemptHTTP2, defaultTransport.ForceAttemptHTTP2)
111 }
112 if transport.IdleConnTimeout != defaultTransport.IdleConnTimeout {
113 t.Fatalf("IdleConnTimeout = %v, want %v", transport.IdleConnTimeout, defaultTransport.IdleConnTimeout)
114 }
115 if transport.TLSHandshakeTimeout != defaultTransport.TLSHandshakeTimeout {
116 t.Fatalf("TLSHandshakeTimeout = %v, want %v", transport.TLSHandshakeTimeout, defaultTransport.TLSHandshakeTimeout)
117 }
118}
119
120func TestBuildHTTPTransportSOCKS5ProxyInheritsDefaultTransportSettings(t *testing.T) {
121 t.Parallel()

Callers

nothing calls this directly

Calls 3

BuildHTTPTransportFunction · 0.85
mustDefaultTransportFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected