Path: blob/main/components/public-api-server/pkg/oidc/state_jwt_test.go
2500 views
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package oidc56import (7"testing"8"time"910"github.com/golang-jwt/jwt/v5"11"github.com/stretchr/testify/require"12)1314func TestNewStateJWT(t *testing.T) {15var (16clientConfigID = "test-id"17returnURL = "test-url"18issuedAt = time.Now()19expiry = issuedAt.Add(5 * time.Minute)20)21token := NewStateJWT(StateParams{22ClientConfigID: clientConfigID,23ReturnToURL: returnURL,24}, issuedAt, expiry)25require.Equal(t, jwt.SigningMethodHS256, token.Method)26require.Equal(t, &StateClaims{27StateParams: StateParams{28ClientConfigID: clientConfigID,29ReturnToURL: returnURL,30},31RegisteredClaims: jwt.RegisteredClaims{32ExpiresAt: jwt.NewNumericDate(expiry),33IssuedAt: jwt.NewNumericDate(issuedAt),34},35}, token.Claims)36}373839