mirror of
https://github.com/gitpod-io/gitpod.git
synced 2025-12-08 17:36:30 +00:00
* [gitpod-db] Add `d_b_oidc_client_config.active` field * [papi] Add OIDCClientConfig.active to proto def * [gitpod-db] Add OIDCClientConfig.active * [papi] Add `activate` param to `/oidc/start` endpoint handler If provided it should mark the OIDC client config as `active` in the DB. * Fix propagation of state params and add tests. * fix import of deprecated ioutil * refactor GetStartParams * consider `activate` from create request
38 lines
951 B
Go
38 lines
951 B
Go
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.
|
|
// Licensed under the GNU Affero General Public License (AGPL).
|
|
// See License.AGPL.txt in the project root for license information.
|
|
|
|
package oidc
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/golang-jwt/jwt/v5"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestNewStateJWT(t *testing.T) {
|
|
var (
|
|
clientConfigID = "test-id"
|
|
returnURL = "test-url"
|
|
issuedAt = time.Now()
|
|
expiry = issuedAt.Add(5 * time.Minute)
|
|
)
|
|
token := NewStateJWT(StateParams{
|
|
ClientConfigID: clientConfigID,
|
|
ReturnToURL: returnURL,
|
|
}, issuedAt, expiry)
|
|
require.Equal(t, jwt.SigningMethodHS256, token.Method)
|
|
require.Equal(t, &StateClaims{
|
|
StateParams: StateParams{
|
|
ClientConfigID: clientConfigID,
|
|
ReturnToURL: returnURL,
|
|
},
|
|
RegisteredClaims: jwt.RegisteredClaims{
|
|
ExpiresAt: jwt.NewNumericDate(expiry),
|
|
IssuedAt: jwt.NewNumericDate(issuedAt),
|
|
},
|
|
}, token.Claims)
|
|
}
|