diff options
author | Nick Thomas <nick@gitlab.com> | 2021-09-15 16:51:41 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2021-09-15 16:51:41 +0000 |
commit | 3f640bdafe429501897541cadf2c268b13c4cf9f (patch) | |
tree | 5713e182841a41acc9e2adfd48697cbfe9eb8e67 /internal/sshd/sshd_test.go | |
parent | 7d60d7a09658041c959c92a7776feceb64b735f4 (diff) | |
parent | e96e13301904bfa6eb514667df9a7803828a7da9 (diff) | |
download | gitlab-shell-3f640bdafe429501897541cadf2c268b13c4cf9f.tar.gz |
Merge branch 'id-sshd-test-3' into 'main'
Extract server config related code out of sshd.go
Closes #523
See merge request gitlab-org/gitlab-shell!523
Diffstat (limited to 'internal/sshd/sshd_test.go')
-rw-r--r-- | internal/sshd/sshd_test.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/internal/sshd/sshd_test.go b/internal/sshd/sshd_test.go index cba1c3f..71f7733 100644 --- a/internal/sshd/sshd_test.go +++ b/internal/sshd/sshd_test.go @@ -104,13 +104,6 @@ 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) @@ -120,6 +113,15 @@ func TestInvalidClientConfig(t *testing.T) { require.Error(t, err) } +func TestInvalidServerConfig(t *testing.T) { + s := &Server{Config: &config.Config{Server: config.ServerConfig{Listen: "invalid"}}} + err := s.ListenAndServe(context.Background()) + + require.Error(t, err) + require.Equal(t, "failed to listen for connection: listen tcp: address invalid: missing port in address", err.Error()) + require.Nil(t, s.Shutdown()) +} + func setupServer(t *testing.T) *Server { t.Helper() |