From c4e65df262168c8a058af03bee2aed9dcdb47bb7 Mon Sep 17 00:00:00 2001 From: Eric Drechsel Date: Sat, 16 Apr 2016 17:45:18 -0700 Subject: [PATCH] Proxy: Add a failing test which replicates #763 2 websocket connections are made instead of one --- caddyhttp/proxy/proxy_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/caddyhttp/proxy/proxy_test.go b/caddyhttp/proxy/proxy_test.go index 866cde95..1535cf7f 100644 --- a/caddyhttp/proxy/proxy_test.go +++ b/caddyhttp/proxy/proxy_test.go @@ -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) {