@@ -428,6 +428,54 @@ func TestSSH(t *testing.T) {
428
428
<- cmdDone
429
429
})
430
430
431
+ t .Run ("RemoteForwardUnixSocket" , func (t * testing.T ) {
432
+ if runtime .GOOS == "windows" {
433
+ t .Skip ("Test not supported on windows" )
434
+ }
435
+
436
+ t .Parallel ()
437
+
438
+ client , workspace , agentToken := setupWorkspaceForAgent (t , nil )
439
+
440
+ _ = agenttest .New (t , client .URL , agentToken )
441
+ coderdtest .AwaitWorkspaceAgents (t , client , workspace .ID )
442
+
443
+ ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
444
+ defer cancel ()
445
+
446
+ tmpdir := tempDirUnixSocket (t )
447
+ agentSock := filepath .Join (tmpdir , "agent.sock" )
448
+ l , err := net .Listen ("unix" , agentSock )
449
+ require .NoError (t , err )
450
+ defer l .Close ()
451
+
452
+ inv , root := clitest .New (t ,
453
+ "ssh" ,
454
+ workspace .Name ,
455
+ "--remote-forward" ,
456
+ agentSock + ":/tmp/test.sock" ,
457
+ )
458
+ clitest .SetupConfig (t , client , root )
459
+ pty := ptytest .New (t ).Attach (inv )
460
+ inv .Stderr = pty .Output ()
461
+ cmdDone := tGo (t , func () {
462
+ err := inv .WithContext (ctx ).Run ()
463
+ assert .NoError (t , err , "ssh command failed" )
464
+ })
465
+
466
+ // Wait for the prompt or any output really to indicate the command has
467
+ // started and accepting input on stdin.
468
+ _ = pty .Peek (ctx , 1 )
469
+
470
+ // Download the test page
471
+ pty .WriteLine ("ss -xl state listening src /var/roo/daemon.sock | wc -l" )
472
+ pty .ExpectMatch ("2" )
473
+
474
+ // And we're done.
475
+ pty .WriteLine ("exit" )
476
+ <- cmdDone
477
+ })
478
+
431
479
t .Run ("FileLogging" , func (t * testing.T ) {
432
480
t .Parallel ()
433
481
0 commit comments