0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-23 22:27:38 -05:00

Proxy: Add a failing test which replicates #763

2 websocket connections are made instead of one
This commit is contained in:
Eric Drechsel 2016-04-16 17:45:18 -07:00 committed by Nimi Wariboko Jr
parent db4cd8ee2d
commit c4e65df262

View file

@ -102,7 +102,8 @@ func TestReverseProxyInsecureSkipVerify(t *testing.T) {
func TestWebSocketReverseProxyServeHTTPHandler(t *testing.T) {
// No-op websocket backend simply allows the WS connection to be
// accepted then it will be immediately closed. Perfect for testing.
wsNop := httptest.NewServer(websocket.Handler(func(ws *websocket.Conn) {}))
var connCount int
wsNop := httptest.NewServer(websocket.Handler(func(ws *websocket.Conn) { connCount++ }))
defer wsNop.Close()
// Get proxy to use for the test
@ -135,6 +136,9 @@ func TestWebSocketReverseProxyServeHTTPHandler(t *testing.T) {
if !bytes.Equal(actual, expected) {
t.Errorf("Expected backend to accept response:\n'%s'\nActually got:\n'%s'", expected, actual)
}
if connCount != 1 {
t.Errorf("Expected 1 websocket connection, got %d", connCount)
}
}
func TestWebSocketReverseProxyFromWSClient(t *testing.T) {