1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-17 18:06:15 -05:00

remove test cases depending on external resources

This commit is contained in:
Darien Raymond 2016-10-24 16:48:16 +02:00
parent 360c222c1c
commit 97dc7b30de
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -13,229 +13,6 @@ import (
. "v2ray.com/core/transport/internet/ws" . "v2ray.com/core/transport/internet/ws"
) )
func Test_Connect_ws(t *testing.T) {
assert := assert.On(t)
conn, err := Dial(v2net.AnyIP, v2net.TCPDestination(v2net.DomainAddress("echo.websocket.org"), 80), internet.DialerOptions{
Stream: &internet.StreamConfig{
Network: v2net.Network_WebSocket,
NetworkSettings: []*internet.NetworkSettings{
{
Network: v2net.Network_WebSocket,
Settings: loader.NewTypedSettings(&Config{
Path: "",
}),
},
},
},
})
assert.Error(err).IsNil()
conn.Write([]byte("echo"))
s := make(chan int)
go func() {
buf := make([]byte, 4)
conn.Read(buf)
str := string(buf)
if str != "echo" {
assert.Fail("Data mismatch")
}
s <- 0
}()
<-s
conn.Close()
}
func Test_Connect_wss(t *testing.T) {
assert := assert.On(t)
conn, err := Dial(v2net.AnyIP, v2net.TCPDestination(v2net.DomainAddress("echo.websocket.org"), 443), internet.DialerOptions{
Stream: &internet.StreamConfig{
Network: v2net.Network_WebSocket,
NetworkSettings: []*internet.NetworkSettings{
{
Network: v2net.Network_WebSocket,
Settings: loader.NewTypedSettings(&Config{
Path: "",
}),
},
},
SecurityType: loader.GetType(new(v2tls.Config)),
},
})
assert.Error(err).IsNil()
conn.Write([]byte("echo"))
s := make(chan int)
go func() {
buf := make([]byte, 4)
conn.Read(buf)
str := string(buf)
if str != "echo" {
assert.Fail("Data mismatch")
}
s <- 0
}()
<-s
conn.Close()
}
func Test_Connect_wss_1_nil(t *testing.T) {
assert := assert.On(t)
conn, err := Dial(nil, v2net.TCPDestination(v2net.DomainAddress("echo.websocket.org"), 443), internet.DialerOptions{
Stream: &internet.StreamConfig{
Network: v2net.Network_WebSocket,
NetworkSettings: []*internet.NetworkSettings{
{
Network: v2net.Network_WebSocket,
Settings: loader.NewTypedSettings(&Config{
Path: "",
}),
},
},
SecurityType: loader.GetType(new(v2tls.Config)),
},
})
assert.Error(err).IsNil()
conn.Write([]byte("echo"))
s := make(chan int)
go func() {
buf := make([]byte, 4)
conn.Read(buf)
str := string(buf)
if str != "echo" {
assert.Fail("Data mismatch")
}
s <- 0
}()
<-s
conn.Close()
}
func Test_Connect_ws_guess(t *testing.T) {
assert := assert.On(t)
conn, err := Dial(v2net.AnyIP, v2net.TCPDestination(v2net.DomainAddress("echo.websocket.org"), 80), internet.DialerOptions{
Stream: &internet.StreamConfig{
Network: v2net.Network_WebSocket,
NetworkSettings: []*internet.NetworkSettings{
{
Network: v2net.Network_WebSocket,
Settings: loader.NewTypedSettings(&Config{
Path: "",
}),
},
},
},
})
assert.Error(err).IsNil()
conn.Write([]byte("echo"))
s := make(chan int)
go func() {
buf := make([]byte, 4)
conn.Read(buf)
str := string(buf)
if str != "echo" {
assert.Fail("Data mismatch")
}
s <- 0
}()
<-s
conn.Close()
}
func Test_Connect_wss_guess(t *testing.T) {
assert := assert.On(t)
conn, err := Dial(v2net.AnyIP, v2net.TCPDestination(v2net.DomainAddress("echo.websocket.org"), 443), internet.DialerOptions{
Stream: &internet.StreamConfig{
Network: v2net.Network_WebSocket,
NetworkSettings: []*internet.NetworkSettings{
{
Network: v2net.Network_WebSocket,
Settings: loader.NewTypedSettings(&Config{
Path: "",
}),
},
},
SecurityType: loader.GetType(new(v2tls.Config)),
},
})
assert.Error(err).IsNil()
conn.Write([]byte("echo"))
s := make(chan int)
go func() {
buf := make([]byte, 4)
conn.Read(buf)
str := string(buf)
if str != "echo" {
assert.Fail("Data mismatch")
}
s <- 0
}()
<-s
conn.Close()
}
func Test_Connect_wss_guess_fail(t *testing.T) {
assert := assert.On(t)
_, err := Dial(v2net.AnyIP, v2net.TCPDestination(v2net.DomainAddress("static.kkdev.org"), 443), internet.DialerOptions{
Stream: &internet.StreamConfig{
Network: v2net.Network_WebSocket,
NetworkSettings: []*internet.NetworkSettings{
{
Network: v2net.Network_WebSocket,
Settings: loader.NewTypedSettings(&Config{
Path: "",
}),
},
},
SecurityType: loader.GetType(new(v2tls.Config)),
},
})
assert.Error(err).IsNotNil()
}
func Test_Connect_wss_guess_reuse(t *testing.T) {
assert := assert.On(t)
i := 3
for i != 0 {
conn, err := Dial(v2net.AnyIP, v2net.TCPDestination(v2net.DomainAddress("echo.websocket.org"), 443), internet.DialerOptions{
Stream: &internet.StreamConfig{
Network: v2net.Network_WebSocket,
NetworkSettings: []*internet.NetworkSettings{
{
Network: v2net.Network_WebSocket,
Settings: loader.NewTypedSettings(&Config{
Path: "",
ConnectionReuse: &ConnectionReuse{
Enable: true,
},
}),
},
},
SecurityType: loader.GetType(new(v2tls.Config)),
},
})
assert.Error(err).IsNil()
conn.Write([]byte("echo"))
s := make(chan int)
go func() {
buf := make([]byte, 4)
conn.Read(buf)
str := string(buf)
if str != "echo" {
assert.Fail("Data mismatch")
}
s <- 0
}()
<-s
if i == 0 {
conn.SetDeadline(time.Now())
conn.SetReadDeadline(time.Now())
conn.SetWriteDeadline(time.Now())
conn.SetReusable(false)
}
conn.Close()
i--
}
}
func Test_listenWSAndDial(t *testing.T) { func Test_listenWSAndDial(t *testing.T) {
assert := assert.On(t) assert := assert.On(t)
listen, err := ListenWS(v2net.DomainAddress("localhost"), 13146, internet.ListenOptions{ listen, err := ListenWS(v2net.DomainAddress("localhost"), 13146, internet.ListenOptions{