MCPcopy
hub / github.com/cloudflare/cloudflared / TestRawTCPServiceEstablishConnection

Function TestRawTCPServiceEstablishConnection

ingress/origin_proxy_test.go:20–41  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18)
19
20func TestRawTCPServiceEstablishConnection(t *testing.T) {
21 originListener, err := net.Listen("tcp", "127.0.0.1:0")
22 require.NoError(t, err)
23
24 listenerClosed := make(chan struct{})
25 tcpListenRoutine(originListener, listenerClosed)
26
27 rawTCPService := &rawTCPService{name: ServiceWarpRouting}
28
29 req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("http://%s", originListener.Addr()), nil)
30 require.NoError(t, err)
31
32 originListener.Close()
33 <-listenerClosed
34
35 req, err = http.NewRequest(http.MethodGet, fmt.Sprintf("http://%s", originListener.Addr()), nil)
36 require.NoError(t, err)
37
38 // Origin not listening for new connection, should return an error
39 _, err = rawTCPService.EstablishConnection(context.Background(), req.URL.String(), TestLogger)
40 require.Error(t, err)
41}
42
43func TestTCPOverWSServiceEstablishConnection(t *testing.T) {
44 originListener, err := net.Listen("tcp", "127.0.0.1:0")

Callers

nothing calls this directly

Calls 7

EstablishConnectionMethod · 0.95
tcpListenRoutineFunction · 0.85
AddrMethod · 0.80
ListenMethod · 0.65
CloseMethod · 0.65
StringMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected