Files
wonderwall/pkg/mock/request.go
Trong Huu Nguyen 5a50ba7c3a feat: support multiple ingresses
Replace hardcoded callback URLs with dynamic generation
of URLs based on incoming requests. These are validated against
a pre-registered list of ingresses for which Wonderwall is considered
authorative for.

We also preserve the cookie behaviour; the most specific ingress path
and domain is used for the cookies.

The `url` package has been moved to the `handler` package, and its
implementation refactored slightly for readability and DRY.
2022-08-17 20:43:56 +02:00

20 lines
493 B
Go

package mock
import (
"net/http"
"net/http/httptest"
mw "github.com/nais/wonderwall/pkg/middleware"
openidconfig "github.com/nais/wonderwall/pkg/openid/config"
)
func NewGetRequest(target string, openidConfig openidconfig.Config) *http.Request {
req := httptest.NewRequest(http.MethodGet, target, nil)
match, ok := openidConfig.Client().Ingresses().MatchingIngress(req)
if ok {
req = mw.RequestWithIngress(req, match)
req = mw.RequestWithPath(req, match.Path())
}
return req
}