blob: 22aabc476e309877b7c9e466961e9e50369aeab9 (
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 authz
import (
"testing"
"github.com/oauth2-proxy/mockoidc"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/web"
)
func TestIDToken(t *testing.T) {
idp := web.NewOIDCServer(t)
defer idp.Close()
t.Run("when the token is valid", func(t *testing.T) {
user := mockoidc.DefaultUser()
_, rawIDToken := idp.CreateTokensFor(user)
token, err := NewIDToken(rawIDToken)
require.NoError(t, err)
require.NotNil(t, token)
})
t.Run("when the token is invalid", func(t *testing.T) {
token, err := NewIDToken("invalid")
require.Error(t, err)
require.Nil(t, token)
})
}
|