2023-06-05 21:40:39 +00:00
// Copyright 2021-2023 the Pinniped contributors. All Rights Reserved.
2021-10-06 22:28:13 +00:00
// SPDX-License-Identifier: Apache-2.0
package testutil
import (
"testing"
"github.com/ory/fosite/handler/openid"
v1 "k8s.io/api/core/v1"
"k8s.io/client-go/kubernetes/fake"
testing2 "k8s.io/client-go/testing"
"go.pinniped.dev/internal/psession"
)
func NewFakePinnipedSession ( ) * psession . PinnipedSession {
return & psession . PinnipedSession {
Fosite : & openid . DefaultSession {
Claims : nil ,
Headers : nil ,
ExpiresAt : nil ,
Username : "snorlax" ,
Subject : "panda" ,
} ,
2021-10-08 22:48:21 +00:00
Custom : & psession . CustomSessionData {
2023-06-05 21:40:39 +00:00
Username : "fake-username" ,
ProviderUID : "fake-provider-uid" ,
ProviderType : "fake-provider-type" ,
ProviderName : "fake-provider-name" ,
UpstreamUsername : "fake-upstream-username" ,
UpstreamGroups : [ ] string { "fake-upstream-group1" , "fake-upstream-group2" } ,
2021-10-06 22:28:13 +00:00
OIDC : & psession . OIDCSessionData {
UpstreamRefreshToken : "fake-upstream-refresh-token" ,
2022-01-07 23:04:58 +00:00
UpstreamSubject : "some-subject" ,
UpstreamIssuer : "some-issuer" ,
2021-10-06 22:28:13 +00:00
} ,
} ,
}
}
func LogActualJSONFromCreateAction ( t * testing . T , client * fake . Clientset , actionIndex int ) {
t . Log ( "actual value of CreateAction secret data" , string ( client . Actions ( ) [ actionIndex ] . ( testing2 . CreateActionImpl ) . Object . ( * v1 . Secret ) . Data [ "pinniped-storage-data" ] ) )
}
func LogActualJSONFromUpdateAction ( t * testing . T , client * fake . Clientset , actionIndex int ) {
t . Log ( "actual value of UpdateAction secret data" , string ( client . Actions ( ) [ actionIndex ] . ( testing2 . UpdateActionImpl ) . Object . ( * v1 . Secret ) . Data [ "pinniped-storage-data" ] ) )
}