Path: blob/main/components/public-api-server/pkg/jws/jwstest/testkeyset.go
2507 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 jwstest56import (7"crypto/rand"8"crypto/rsa"9"testing"1011"github.com/gitpod-io/gitpod/public-api-server/pkg/jws"12"github.com/stretchr/testify/require"13)1415func GenerateKeySet(t *testing.T) jws.KeySet {16return jws.KeySet{17Signing: GenerateRSAPrivateKey(t, "0001"),18Validating: []jws.Key{19GenerateRSAPrivateKey(t, "0002"),20GenerateRSAPrivateKey(t, "0003"),21},22}23}2425func GenerateRSAPrivateKey(t *testing.T, id string) jws.Key {26t.Helper()2728privateKey, err := rsa.GenerateKey(rand.Reader, 2048)29require.NoError(t, err)30return jws.Key{31ID: id,32Private: privateKey,33}34}353637