aboutsummaryrefslogtreecommitdiff
path: root/ssh/test
diff options
context:
space:
mode:
authorTugdual Saunier <tugdual.saunier@gmail.com>2017-09-21 10:41:56 -0700
committerHan-Wen Nienhuys <hanwen@google.com>2017-11-13 21:34:09 +0000
commit9f005a07e0d31d45e6656d241bb5c0f2efd4bc94 (patch)
treea67aad87c874abb2a8a4a881e7b4a4d67dc989db /ssh/test
parent6a293f2d4b14b8e6d3f0539e383f6d0d30fce3fd (diff)
downloadgo-x-crypto-9f005a07e0d31d45e6656d241bb5c0f2efd4bc94.tar.xz
ssh: add support for banners
According to RFC 4252 section 5.4, the banner is sent between the ssh-connection request and responding to user authentication. Original support for server sending banner by joshua stein <jcs@jcs.org> Fixes golang/go#19567 Change-Id: I729b3c8e5fd2c0068609d1590b61e92f40d87ea4 Reviewed-on: https://go-review.googlesource.com/71790 Run-TryBot: Han-Wen Nienhuys <hanwen@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
Diffstat (limited to 'ssh/test')
-rw-r--r--ssh/test/banner_test.go33
-rw-r--r--ssh/test/test_unix_test.go3
2 files changed, 36 insertions, 0 deletions
diff --git a/ssh/test/banner_test.go b/ssh/test/banner_test.go
new file mode 100644
index 0000000..f1ad469
--- /dev/null
+++ b/ssh/test/banner_test.go
@@ -0,0 +1,33 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin dragonfly freebsd linux netbsd openbsd
+
+package test
+
+import (
+ "testing"
+
+)
+
+func TestBannerCallbackAgainstOpenSSH(t *testing.T) {
+ server := newServer(t)
+ defer server.Shutdown()
+
+ clientConf := clientConfig()
+
+ var receivedBanner string
+ clientConf.BannerCallback = func(message string) error {
+ receivedBanner = message
+ return nil
+ }
+
+ conn := server.Dial(clientConf)
+ defer conn.Close()
+
+ expected := "Server Banner"
+ if receivedBanner != expected {
+ t.Fatalf("got %v; want %v", receivedBanner, expected)
+ }
+}
diff --git a/ssh/test/test_unix_test.go b/ssh/test/test_unix_test.go
index e673536..6b1e0ff 100644
--- a/ssh/test/test_unix_test.go
+++ b/ssh/test/test_unix_test.go
@@ -27,6 +27,7 @@ import (
const sshd_config = `
Protocol 2
+Banner {{.Dir}}/banner
HostKey {{.Dir}}/id_rsa
HostKey {{.Dir}}/id_dsa
HostKey {{.Dir}}/id_ecdsa
@@ -256,6 +257,8 @@ func newServer(t *testing.T) *server {
}
f.Close()
+ writeFile(filepath.Join(dir, "banner"), []byte("Server Banner"))
+
for k, v := range testdata.PEMBytes {
filename := "id_" + k
writeFile(filepath.Join(dir, filename), v)