summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Drozdov <idrozdov@gitlab.com>2021-09-14 14:37:47 +0300
committerIgor Drozdov <idrozdov@gitlab.com>2021-09-15 06:55:10 +0300
commitf3c967026ec5cb4bf6fb818e282404d8fd69be03 (patch)
tree01a051459b0b5400f1871fedd02fa9e33c0a66ec
parent7a1c179d1397098565492b8538fd22891a44c843 (diff)
downloadgitlab-shell-id-sshd-tests.tar.gz
Add TestInvalidClientConfig and TestNewServerWithoutHosts for sshd.goid-sshd-tests
-rw-r--r--internal/sshd/sshd_test.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/sshd/sshd_test.go b/internal/sshd/sshd_test.go
index 32946af..cba1c3f 100644
--- a/internal/sshd/sshd_test.go
+++ b/internal/sshd/sshd_test.go
@@ -104,6 +104,22 @@ func TestLivenessProbe(t *testing.T) {
require.Equal(t, 200, r.Result().StatusCode)
}
+func TestNewServerWithoutHosts(t *testing.T) {
+ _, err := NewServer(&config.Config{GitlabUrl: "http://localhost"})
+
+ require.Error(t, err)
+ require.Equal(t, "No host keys could be loaded, aborting", err.Error())
+}
+
+func TestInvalidClientConfig(t *testing.T) {
+ setupServer(t)
+
+ cfg := clientConfig(t)
+ cfg.User = "unknown"
+ _, err := ssh.Dial("tcp", serverUrl, cfg)
+ require.Error(t, err)
+}
+
func setupServer(t *testing.T) *Server {
t.Helper()