MCPcopy Create free account
hub / github.com/tailscale/tailcat / sshClient

Method sshClient

tailcat_ssh_test.go:62–81  ·  view source on GitHub ↗

sshClient dials the server's SSH port and returns a connected gossh.Client.

(t *testing.T)

Source from the content-addressed store, hash-verified

60
61// sshClient dials the server's SSH port and returns a connected gossh.Client.
62func (e *testSSHEnv) sshClient(t *testing.T) *gossh.Client {
63 t.Helper()
64 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
65 defer cancel()
66
67 conn, err := e.client.DialTCPPort(ctx, 22)
68 if err != nil {
69 t.Fatalf("DialTCPPort(22): %v", err)
70 }
71 sshConn, chans, reqs, err := gossh.NewClientConn(conn, "server", &gossh.ClientConfig{
72 HostKeyCallback: gossh.InsecureIgnoreHostKey(),
73 })
74 if err != nil {
75 conn.Close()
76 t.Fatalf("NewClientConn: %v", err)
77 }
78 c := gossh.NewClient(sshConn, chans, reqs)
79 t.Cleanup(func() { c.Close() })
80 return c
81}
82
83func TestSSHSuite(t *testing.T) {
84 t.Parallel()

Callers 1

TestSSHSuiteFunction · 0.80

Calls 3

CloseMethod · 0.95
DialTCPPortMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected