Skip to content

Commit

Permalink
fixed unit-test
Browse files Browse the repository at this point in the history
  • Loading branch information
okankoAMZ committed Nov 13, 2024
1 parent b551012 commit d59fed3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
Expand Down Expand Up @@ -73,7 +74,13 @@ func WithTLSConfig(tlsConfig *tls.Config, httpsListenAddr string) Option {
s.setRouter(httpsRouter)

s.httpsServer = &http.Server{Addr: httpsListenAddr, Handler: httpsRouter, ReadHeaderTimeout: 90 * time.Second, TLSConfig: tlsConfig}
s.server.Shutdown(context.Background())
err := s.server.Shutdown(context.Background())
if err != nil {
s.logger.Error(err, "Failed to shutdown http server")
}
if errors.Is(err, http.ErrServerClosed) {
s.logger.Info("Http server is already closed")
}
s.server = s.httpsServer
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ func TestServer_Readiness(t *testing.T) {
}

func TestServer_ValidCAonTLS(t *testing.T) {
listenAddr := ":8443"
listenAddr := ""
server, clientTlsConfig, err := createTestTLSServer(listenAddr)
assert.NoError(t, err)
go func() {
Expand Down Expand Up @@ -735,7 +735,7 @@ func TestServer_ValidCAonTLS(t *testing.T) {
}

func TestServer_MissingCAonTLS(t *testing.T) {
listenAddr := ":8443"
listenAddr := ""
server, _, err := createTestTLSServer(listenAddr)
assert.NoError(t, err)
go func() {
Expand Down Expand Up @@ -780,7 +780,7 @@ func TestServer_MissingCAonTLS(t *testing.T) {
}

func TestServer_HTTPOnTLS(t *testing.T) {
listenAddr := ":8443"
listenAddr := ""
server, _, err := createTestTLSServer(listenAddr)
assert.NoError(t, err)
go func() {
Expand Down

0 comments on commit d59fed3

Please sign in to comment.