summaryrefslogtreecommitdiff
path: root/internal/sshd/sshd_test.go
diff options
context:
space:
mode:
authorIgor Drozdov <idrozdov@gitlab.com>2021-09-15 18:58:27 +0300
committerIgor Drozdov <idrozdov@gitlab.com>2021-09-15 19:41:33 +0300
commite96e13301904bfa6eb514667df9a7803828a7da9 (patch)
tree5713e182841a41acc9e2adfd48697cbfe9eb8e67 /internal/sshd/sshd_test.go
parent7d60d7a09658041c959c92a7776feceb64b735f4 (diff)
downloadgitlab-shell-e96e13301904bfa6eb514667df9a7803828a7da9.tar.gz
Extract server config related code out of sshd.go
Diffstat (limited to 'internal/sshd/sshd_test.go')
-rw-r--r--internal/sshd/sshd_test.go16
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()