MCPcopy
hub / github.com/gliderlabs/ssh / newTestSessionWithForwarding

Function newTestSessionWithForwarding

tcpip_test.go:31–49  ·  view source on GitHub ↗
(t *testing.T, forwardingEnabled bool)

Source from the content-addressed store, hash-verified

29}
30
31func newTestSessionWithForwarding(t *testing.T, forwardingEnabled bool) (net.Listener, *gossh.Client, func()) {
32 l := sampleSocketServer()
33
34 _, client, cleanup := newTestSession(t, &Server{
35 Handler: func(s Session) {},
36 LocalPortForwardingCallback: func(ctx Context, destinationHost string, destinationPort uint32) bool {
37 addr := net.JoinHostPort(destinationHost, strconv.FormatInt(int64(destinationPort), 10))
38 if addr != l.Addr().String() {
39 panic("unexpected destinationHost: " + addr)
40 }
41 return forwardingEnabled
42 },
43 }, nil)
44
45 return l, client, func() {
46 cleanup()
47 l.Close()
48 }
49}
50
51func TestLocalPortForwardingWorks(t *testing.T) {
52 t.Parallel()

Calls 3

sampleSocketServerFunction · 0.85
newTestSessionFunction · 0.85
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…