6
6
"net"
7
7
"os"
8
8
"os/exec"
9
- "path/filepath"
10
9
"strings"
11
10
"testing"
12
11
@@ -27,6 +26,11 @@ import (
27
26
28
27
func TestConfigSSH (t * testing.T ) {
29
28
t .Parallel ()
29
+ _ , err := exec .LookPath ("socat" )
30
+ if err != nil {
31
+ t .Skip ("You must have socat installed to run this test!" )
32
+ }
33
+
30
34
client := coderdtest .New (t , nil )
31
35
user := coderdtest .CreateFirstUser (t , client )
32
36
coderdtest .NewProvisionerDaemon (t , client )
@@ -85,13 +89,15 @@ func TestConfigSSH(t *testing.T) {
85
89
require .NoError (t , err )
86
90
defer agentConn .Close ()
87
91
88
- // Using socat we can force SSH to use a UNIX socket
92
+ // Using socat we can force SSH to use a TCP port
89
93
// created in this test. That way we still validate
90
94
// our configuration, but use the native SSH command
91
95
// line to interface.
92
- socket := filepath .Join (t .TempDir (), "ssh" )
93
- listener , err := net .Listen ("unix" , socket )
96
+ listener , err := net .Listen ("tcp" , "127.0.0.1:0" )
94
97
require .NoError (t , err )
98
+ t .Cleanup (func () {
99
+ _ = listener .Close ()
100
+ })
95
101
go func () {
96
102
for {
97
103
conn , err := listener .Accept ()
@@ -108,7 +114,7 @@ func TestConfigSSH(t *testing.T) {
108
114
_ = listener .Close ()
109
115
})
110
116
111
- cmd , root := clitest .New (t , "config-ssh" , "--ssh-option" , "ProxyCommand socat - UNIX-CLIENT :" + socket , "--ssh-config-file" , tempFile .Name ())
117
+ cmd , root := clitest .New (t , "config-ssh" , "--ssh-option" , "ProxyCommand socat - TCP4 :" + listener . Addr (). String () , "--ssh-config-file" , tempFile .Name ())
112
118
clitest .SetupConfig (t , client , root )
113
119
doneChan := make (chan struct {})
114
120
pty := ptytest .New (t )
0 commit comments