blob: 054c48b91a1e8363f0b588725c4baf8c32530e4a (
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
31
|
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)
t.Logf("id_token: %v\n", rawIDToken)
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)
})
}
|