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

Function TestProxyWithConfigWebSocketNonTLS2TLS

middleware/proxy_test.go:1084–1122  ·  view source on GitHub ↗

TestProxyWithConfigWebSocketNonTLS2TLS tests the proxy with non-TLS to TLS WebSocket connection.

(t *testing.T)

Source from the content-addressed store, hash-verified

1082
1083// TestProxyWithConfigWebSocketNonTLS2TLS tests the proxy with non-TLS to TLS WebSocket connection.
1084func TestProxyWithConfigWebSocketNonTLS2TLS(t *testing.T) {
1085 /*
1086 Arrange
1087 */
1088
1089 // Create a WebSocket test server (TLS)
1090 srv := createSimpleWebSocketServer(true)
1091 defer srv.Close()
1092
1093 // create proxy server (Non-TLS to TLS)
1094 ts := createSimpleProxyServer(t, srv, false, true)
1095 defer ts.Close()
1096
1097 tsURL, _ := url.Parse(ts.URL)
1098 tsURL.Scheme = "ws"
1099 tsURL.Path = "/"
1100
1101 /*
1102 Act
1103 */
1104 // Connect to the proxy WebSocket
1105 wsConn, err := websocket.Dial(tsURL.String(), "", "http://localhost/")
1106 assert.NoError(t, err)
1107 defer wsConn.Close()
1108
1109 // Send message
1110 sendMsg := "Hello, Non TLS to TLS WebSocket!"
1111 err = websocket.Message.Send(wsConn, sendMsg)
1112 assert.NoError(t, err)
1113
1114 /*
1115 Assert
1116 */
1117 // Read response
1118 var recvMsg string
1119 err = websocket.Message.Receive(wsConn, &recvMsg)
1120 assert.NoError(t, err)
1121 assert.Equal(t, sendMsg, recvMsg)
1122}
1123
1124// TestProxyWithConfigWebSocketTLSToNoneTLS tests the proxy with TLS to non-TLS WebSocket connection. (TLS termination)
1125func TestProxyWithConfigWebSocketTLS2NonTLS(t *testing.T) {

Callers

nothing calls this directly

Calls 4

createSimpleProxyServerFunction · 0.85
CloseMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…