From 05597b3e6a6c9761af7c5fcd2d11e238db5955fd Mon Sep 17 00:00:00 2001 From: Oliver Graff Date: Wed, 14 Jun 2017 06:07:24 -0700 Subject: [PATCH] Fix unit tests / Travis (#238) * Fix net_test * Update host test to add carriage return char * Fix host_test so it will not hang if the SSH connection fails Fixes #231, closes #235. --- host_test.go | 7 +++++-- sshd/client.go | 1 + sshd/net_test.go | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/host_test.go b/host_test.go index 7c2f976..f98724a 100644 --- a/host_test.go +++ b/host_test.go @@ -71,7 +71,7 @@ func TestHostNameCollision(t *testing.T) { // Consume the initial buffer scanner.Scan() actual := stripPrompt(scanner.Text()) - expected := " * foo joined. (Connected: 1)" + expected := " * foo joined. (Connected: 1)\r" if actual != expected { t.Errorf("Got %q; expected %q", actual, expected) } @@ -87,7 +87,7 @@ func TestHostNameCollision(t *testing.T) { t.Errorf("First client failed to get 'foo' name: %q", actual) } actual = stripPrompt(actual) - expected = " * Guest1 joined. (Connected: 2)" + expected = " * Guest1 joined. (Connected: 2)\r" if actual != expected { t.Errorf("Got %q; expected %q", actual, expected) } @@ -97,6 +97,7 @@ func TestHostNameCollision(t *testing.T) { return nil }) if err != nil { + done <- struct{}{} t.Fatal(err) } }() @@ -203,6 +204,7 @@ func TestHostKick(t *testing.T) { return nil }) if err != nil { + connected <- struct{}{} close(connected) t.Fatal(err) } @@ -218,6 +220,7 @@ func TestHostKick(t *testing.T) { return nil }) if err != nil { + close(done) t.Fatal(err) } close(done) diff --git a/sshd/client.go b/sshd/client.go index 47cbc5a..004aa47 100644 --- a/sshd/client.go +++ b/sshd/client.go @@ -26,6 +26,7 @@ func NewClientConfig(name string) *ssh.ClientConfig { return }), }, + HostKeyCallback: ssh.InsecureIgnoreHostKey(), } } diff --git a/sshd/net_test.go b/sshd/net_test.go index b9b3f9f..6d6d627 100644 --- a/sshd/net_test.go +++ b/sshd/net_test.go @@ -52,7 +52,7 @@ func TestServeTerminals(t *testing.T) { if err != nil { t.Error(err) } - _, err = term.Write([]byte("echo: " + line + "\r\n")) + _, err = term.Write([]byte("echo: " + line + "\n")) if err != nil { t.Error(err) }