Skip to content

Commit

Permalink
Merge pull request #41 from corbado/40-use-random-port-for-session-un…
Browse files Browse the repository at this point in the history
…it-test

Use random port for session tests
  • Loading branch information
corbadovych authored Oct 15, 2024
2 parents b3c20a4 + 3d9e80e commit 4b8828f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tests/unit/session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"io"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -82,15 +83,13 @@ func newSession(issuer string) (*session.Impl, error) {
}
})

server := &http.Server{Addr: "localhost:8081", Handler: mockServer} // nolint:gosec
go func() {
_ = server.ListenAndServe()
}()
server := httptest.NewServer(mockServer)
defer server.Close()

// Config
config := &session.Config{
ProjectID: "pro-1",
JwksURI: "http://localhost:8081",
JwksURI: server.URL,
JWTIssuer: issuer,
}

Expand Down Expand Up @@ -125,7 +124,7 @@ func newSession(issuer string) (*session.Impl, error) {
RefreshUnknownKID: true,
}

jwks, err := keyfunc.Get("http://localhost:8081", options)
jwks, err := keyfunc.Get(server.URL, options)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 4b8828f

Please sign in to comment.