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:
parent
db4cd8ee2d
commit
c4e65df262
1 changed files with 5 additions and 1 deletions
|
@ -102,7 +102,8 @@ func TestReverseProxyInsecureSkipVerify(t *testing.T) {
|
||||||
func TestWebSocketReverseProxyServeHTTPHandler(t *testing.T) {
|
func TestWebSocketReverseProxyServeHTTPHandler(t *testing.T) {
|
||||||
// No-op websocket backend simply allows the WS connection to be
|
// No-op websocket backend simply allows the WS connection to be
|
||||||
// accepted then it will be immediately closed. Perfect for testing.
|
// 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()
|
defer wsNop.Close()
|
||||||
|
|
||||||
// Get proxy to use for the test
|
// Get proxy to use for the test
|
||||||
|
@ -135,6 +136,9 @@ func TestWebSocketReverseProxyServeHTTPHandler(t *testing.T) {
|
||||||
if !bytes.Equal(actual, expected) {
|
if !bytes.Equal(actual, expected) {
|
||||||
t.Errorf("Expected backend to accept response:\n'%s'\nActually got:\n'%s'", expected, actual)
|
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) {
|
func TestWebSocketReverseProxyFromWSClient(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue