Skip to content

Commit 31ae487

Browse files
authored
Merge branch 'main' into add-tools-resources
2 parents c479016 + d15828a commit 31ae487

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

pkg/oidc/check/flow_test.go

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package check_test
33
import (
44
"context"
55
"fmt"
6-
"net"
76
"net/http"
7+
"net/http/httptest"
88
"strings"
99
"testing"
1010
"time"
@@ -21,7 +21,7 @@ import (
2121
)
2222

2323
type TestProvider struct {
24-
srv *http.Server
24+
srv *httptest.Server
2525
URL string
2626
RequestedScopes []string
2727
GenClaims func() jwt.Claims
@@ -38,17 +38,7 @@ func (tp TestProvider) genToken() string {
3838
}
3939

4040
func (tp *TestProvider) Start() error {
41-
listener, err := net.Listen("tcp", "127.0.0.1:8765")
42-
if err != nil {
43-
return fmt.Errorf("failed starting listener: %w", err)
44-
}
45-
46-
tp.URL = fmt.Sprintf("http://%s", listener.Addr().String())
47-
mux := http.ServeMux{}
48-
tp.srv = &http.Server{
49-
Handler: &mux,
50-
ReadHeaderTimeout: 5 * time.Second,
51-
}
41+
mux := &http.ServeMux{}
5242

5343
mux.HandleFunc("/.well-known/openid-configuration", func(w http.ResponseWriter, r *http.Request) {
5444
w.Header().Add("content-type", "application/json")
@@ -72,13 +62,14 @@ func (tp *TestProvider) Start() error {
7262
}`, tp.genToken())
7363
})
7464

75-
go tp.srv.Serve(listener)
65+
tp.srv = httptest.NewServer(mux)
66+
tp.URL = tp.srv.URL
7667

7768
return nil
7869
}
7970

8071
func (tp TestProvider) Shutdown() {
81-
tp.srv.Shutdown(context.Background())
72+
tp.srv.Close()
8273
}
8374

8475
func (tp TestProvider) IssuerURL() string {

0 commit comments

Comments
 (0)