mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-30 19:06:33 +02:00
* core/authorize: check for expired tokens * Update pkg/grpc/session/session.go Co-authored-by: Denis Mishin <dmishin@pomerium.com> * lint * fix zero timestamps * fix --------- Co-authored-by: Denis Mishin <dmishin@pomerium.com>
32 lines
746 B
Go
32 lines
746 B
Go
package session
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
)
|
|
|
|
func TestSession_Validate(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
t0 := timestamppb.New(time.Now().Add(-time.Second))
|
|
for _, tc := range []struct {
|
|
name string
|
|
session *Session
|
|
expect error
|
|
}{
|
|
{"valid", &Session{}, nil},
|
|
{"expired", &Session{ExpiresAt: t0}, ErrSessionExpired},
|
|
{"expired id token", &Session{IdToken: &IDToken{ExpiresAt: t0}}, ErrSessionExpired},
|
|
{"expired oauth token", &Session{OauthToken: &OAuthToken{ExpiresAt: t0}}, ErrSessionExpired},
|
|
} {
|
|
tc := tc
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
assert.ErrorIs(t, tc.session.Validate(), tc.expect)
|
|
})
|
|
}
|
|
}
|