summaryrefslogtreecommitdiff
path: root/test/integration/oidc.go
blob: 9fa465e0c7053297014bc467d94ab847c2b82b26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package test

import (
	"net/http"
	"testing"

	"github.com/oauth2-proxy/mockoidc"
	"github.com/stretchr/testify/require"
)

func NewOIDCTestServer(t *testing.T) *mockoidc.MockOIDC {
	srv, err := mockoidc.Run()
	require.NoError(t, err)

	srv.AddMiddleware(func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			t.Logf("%v %v %v\n", r.Method, r.URL.Path, r.URL.Query())
			next.ServeHTTP(w, r)
		})
	})

	return srv
}