From 97dc7b30de52a3e71e2cc78edcadf75a3be7dfd1 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Mon, 24 Oct 2016 16:48:16 +0200 Subject: [PATCH] remove test cases depending on external resources --- transport/internet/ws/ws_test.go | 223 ------------------------------- 1 file changed, 223 deletions(-) diff --git a/transport/internet/ws/ws_test.go b/transport/internet/ws/ws_test.go index 949a7f36..c15eeb19 100644 --- a/transport/internet/ws/ws_test.go +++ b/transport/internet/ws/ws_test.go @@ -13,229 +13,6 @@ import ( . "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) { assert := assert.On(t) listen, err := ListenWS(v2net.DomainAddress("localhost"), 13146, internet.ListenOptions{