1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 09:36:34 -05:00

test case for http proxy error

This commit is contained in:
Darien Raymond 2018-04-18 22:41:47 +02:00
parent be1c175de6
commit 0ad4f99762
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -16,6 +16,7 @@ import (
"v2ray.com/core/app/proxyman"
"v2ray.com/core/common/net"
"v2ray.com/core/common/serial"
"v2ray.com/core/proxy/blackhole"
"v2ray.com/core/proxy/freedom"
v2http "v2ray.com/core/proxy/http"
v2httptest "v2ray.com/core/testing/servers/http"
@ -80,6 +81,49 @@ func TestHttpConformance(t *testing.T) {
CloseAllServers(servers)
}
func TestHttpError(t *testing.T) {
assert := With(t)
serverPort := tcp.PickPort()
serverConfig := &core.Config{
Inbound: []*core.InboundHandlerConfig{
{
ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{
PortRange: net.SinglePortRange(serverPort),
Listen: net.NewIPOrDomain(net.LocalHostIP),
}),
ProxySettings: serial.ToTypedMessage(&v2http.ServerConfig{}),
},
},
Outbound: []*core.OutboundHandlerConfig{
{
ProxySettings: serial.ToTypedMessage(&blackhole.Config{}),
},
},
}
servers, err := InitializeServerConfigs(serverConfig)
assert(err, IsNil)
{
transport := &http.Transport{
Proxy: func(req *http.Request) (*url.URL, error) {
return url.Parse("http://127.0.0.1:" + serverPort.String())
},
}
client := &http.Client{
Transport: transport,
}
resp, err := client.Get("http://127.0.0.1:80")
assert(err, IsNil)
assert(resp.StatusCode, Equals, 503)
}
CloseAllServers(servers)
}
func TestHttpConnectMethod(t *testing.T) {
assert := With(t)