(t *testing.T, config config.AppConfig)
| 71 | } |
| 72 | |
| 73 | func 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 | } |
no test coverage detected