diff options
author | Nick Thomas <nick@gitlab.com> | 2021-09-15 09:12:27 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2021-09-15 09:12:27 +0000 |
commit | e16dce62a1773eee0e92b1e5b21cce9328c785de (patch) | |
tree | 01a051459b0b5400f1871fedd02fa9e33c0a66ec | |
parent | 7a1c179d1397098565492b8538fd22891a44c843 (diff) | |
parent | f3c967026ec5cb4bf6fb818e282404d8fd69be03 (diff) | |
download | gitlab-shell-e16dce62a1773eee0e92b1e5b21cce9328c785de.tar.gz |
Merge branch 'id-sshd-tests' into 'main'
Add TestInvalidClientConfig and TestNewServerWithoutHosts for sshd.go
See merge request gitlab-org/gitlab-shell!518
-rw-r--r-- | internal/sshd/sshd_test.go | 16 |
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() |