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

import (
	"context"
	"testing"

	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
	"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/test"
)

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

	t.Run("GET /.well-known/openid-configuration", func(t *testing.T) {
		openID, err := New(context.Background(), srv.Issuer(), "client_id", "client_secret", "https://example.com/oauth/callback")
		require.NoError(t, err)

		assert.Equal(t, srv.AuthorizationEndpoint(), openID.Provider.Endpoint().AuthURL)
	})
}