MCPcopy Index your code
hub / github.com/labstack/echo / TestProxyWithConfigWebSocketTLS2TLS

Function TestProxyWithConfigWebSocketTLS2TLS

middleware/proxy_test.go:1040–1081  ·  view source on GitHub ↗

TestProxyWithConfigWebSocketTLS2TLS tests the proxy with TLS to TLS WebSocket connection.

(t *testing.T)

Source from the content-addressed store, hash-verified

1038
1039// TestProxyWithConfigWebSocketTLS2TLS tests the proxy with TLS to TLS WebSocket connection.
1040func TestProxyWithConfigWebSocketTLS2TLS(t *testing.T) {
1041 /*
1042 Arrange
1043 */
1044 // Create a WebSocket test server (TLS)
1045 srv := createSimpleWebSocketServer(true)
1046 defer srv.Close()
1047
1048 // create proxy server (TLS to TLS)
1049 ts := createSimpleProxyServer(t, srv, true, true)
1050 defer ts.Close()
1051
1052 tsURL, _ := url.Parse(ts.URL)
1053 tsURL.Scheme = "wss"
1054 tsURL.Path = "/"
1055
1056 /*
1057 Act
1058 */
1059 origin, err := url.Parse(ts.URL)
1060 assert.NoError(t, err)
1061 config := &websocket.Config{
1062 Location: tsURL,
1063 Origin: origin,
1064 TlsConfig: &tls.Config{InsecureSkipVerify: true}, // skip verify for testing
1065 Version: websocket.ProtocolVersionHybi13,
1066 }
1067 wsConn, err := websocket.DialConfig(config)
1068 assert.NoError(t, err)
1069 defer wsConn.Close()
1070
1071 // Send message
1072 sendMsg := "Hello, TLS to TLS WebSocket!"
1073 err = websocket.Message.Send(wsConn, sendMsg)
1074 assert.NoError(t, err)
1075
1076 // Read response
1077 var recvMsg string
1078 err = websocket.Message.Receive(wsConn, &recvMsg)
1079 assert.NoError(t, err)
1080 assert.Equal(t, sendMsg, recvMsg)
1081}
1082
1083// TestProxyWithConfigWebSocketNonTLS2TLS tests the proxy with non-TLS to TLS WebSocket connection.
1084func TestProxyWithConfigWebSocketNonTLS2TLS(t *testing.T) {

Callers

nothing calls this directly

Calls 3

createSimpleProxyServerFunction · 0.85
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…