@@ -2,7 +2,6 @@ package e2e
22
33import (
44 "fmt"
5- "golang.org/x/sync/errgroup"
65 "log"
76 "net"
87 "os"
@@ -13,6 +12,7 @@ import (
1312 "time"
1413
1514 xproxy "golang.org/x/net/proxy"
15+ "golang.org/x/sync/errgroup"
1616)
1717
1818var server * sshServer
@@ -56,6 +56,33 @@ func TestList(t *testing.T) {
5656 }
5757}
5858
59+ func TestListNoTunnels (t * testing.T ) {
60+ cfg := defaultConfig
61+ cfg .boringConfig = t .TempDir () + "/config.toml"
62+ f , err := os .Create (cfg .boringConfig )
63+ if err != nil {
64+ t .Fatalf ("could not create config file: %v" , err )
65+ }
66+ f .Close ()
67+
68+ env , cancel , err := makeEnvWithDaemon (cfg , t )
69+ if err != nil {
70+ t .Fatalf (err .Error ())
71+ }
72+ defer cancel ()
73+
74+ c , out , err := cliCommand (env , "list" )
75+ if err != nil {
76+ t .Fatalf ("failed to run CLI command: %v" , err )
77+ }
78+ if c != 0 {
79+ t .Fatalf ("exit code %d: %s" , c , out )
80+ }
81+ if ! strings .Contains (out , "No tunnels configured." ) {
82+ t .Fatalf ("did not get expected output: %v" , out )
83+ }
84+ }
85+
5986func TestOpen (t * testing.T ) {
6087 env , cancel , err := makeDefaultEnvWithDaemon (t )
6188 if err != nil {
@@ -408,7 +435,7 @@ func TestTunnelLocal(t *testing.T) {
408435}
409436
410437// Test handling of multiple simultaneous connections
411- func TestTunnelMulti (t * testing.T ) {
438+ func TestTunnelMultiConns (t * testing.T ) {
412439 env , cancel , err := makeDefaultEnvWithDaemon (t )
413440 if err != nil {
414441 t .Fatalf (err .Error ())
@@ -450,6 +477,30 @@ func TestTunnelMulti(t *testing.T) {
450477 }
451478}
452479
480+ func TestTunnelMultiTunnels (t * testing.T ) {
481+ env , cancel , err := makeDefaultEnvWithDaemon (t )
482+ if err != nil {
483+ t .Fatalf (err .Error ())
484+ }
485+ defer cancel ()
486+
487+ c , out , err := cliCommand (env , "open" , "test" , "test2" )
488+ if err != nil {
489+ t .Fatalf ("failed to run CLI command: %v" , err )
490+ }
491+ if c != 0 {
492+ t .Fatalf ("exit code %d: %s" , c , out )
493+ }
494+ out = stripANSI (out )
495+ if ! strings .Contains (strings .ToLower (out ), "opened tunnel 'test'" ) ||
496+ ! strings .Contains (strings .ToLower (out ), "opened tunnel 'test2'" ) {
497+ t .Errorf ("output did not indicate success: %s" , out )
498+ }
499+
500+ testTunnel (t , "localhost:49711" , "localhost:49712" )
501+ testTunnel (t , "localhost:49713" , "localhost:49714" )
502+ }
503+
453504// Test a reverse connection
454505func TestTunnelRemote (t * testing.T ) {
455506 env , cancel , err := makeDefaultEnvWithDaemon (t )
0 commit comments