MCPcopy
hub / github.com/ContainerSSH/ContainerSSH / processClientInteraction

Function processClientInteraction

internal/backend/integration_test.go:73–99  ·  view source on GitHub ↗
(t *testing.T, config config.AppConfig)

Source from the content-addressed store, hash-verified

71}
72
73func processClientInteraction(t *testing.T, config config.AppConfig) {
74 clientConfig := &ssh.ClientConfig{
75 User: "foo",
76 Auth: []ssh.AuthMethod{ssh.Password("bar")},
77 }
78 clientConfig.HostKeyCallback = func(hostname string, remote net.Addr, key ssh.PublicKey) error {
79 return nil
80 }
81 sshConnection, err := ssh.Dial("tcp", config.SSH.Listen, clientConfig)
82 if !assert.NoError(t, err) {
83 return
84 }
85 defer func() {
86 if sshConnection != nil {
87 _ = sshConnection.Close()
88 }
89 }()
90
91 session, err := sshConnection.NewSession()
92 assert.NoError(t, err)
93
94 output, err := session.CombinedOutput("echo 'Hello world!'")
95 assert.NoError(t, err)
96
97 assert.NoError(t, sshConnection.Close())
98 assert.EqualValues(t, []byte("Hello world!\n"), output)
99}

Callers 1

Calls 2

PasswordMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected