summaryrefslogtreecommitdiff
path: root/pkg/web/oidc_server_test.go
blob: 74d74d9a8e4f843141d4fd20e3ca97a27ccaf426 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package web

import (
	"net/http"
	"strings"
	"testing"

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

func TestOIDCServer(t *testing.T) {
	srv := NewOIDCServer(t)
	defer srv.Close()

	t.Run("provides a working discover endpoints", func(t *testing.T) {
		response, err := http.Get(srv.DiscoveryEndpoint())

		require.NoError(t, err)
		require.Equal(t, http.StatusOK, response.StatusCode)
	})

	t.Run("maps the gitlab oauth routes to the mockoidc ones", func(t *testing.T) {
		url := srv.Addr() + strings.Replace(mockoidc.DiscoveryEndpoint, mockoidc.IssuerBase, mockoidc.IssuerBase+"/oauth", 1)
		response, err := http.Get(url)

		require.NoError(t, err)
		require.Equal(t, http.StatusOK, response.StatusCode)
	})
}