mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-30 10:56:28 +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>
30 lines
623 B
Go
30 lines
623 B
Go
package user
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
)
|
|
|
|
func TestServiceAccount_Validate(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
t0 := timestamppb.New(time.Now().Add(-time.Second))
|
|
for _, tc := range []struct {
|
|
name string
|
|
serviceAccount *ServiceAccount
|
|
expect error
|
|
}{
|
|
{"valid", &ServiceAccount{}, nil},
|
|
{"expired", &ServiceAccount{ExpiresAt: t0}, ErrServiceAccountExpired},
|
|
} {
|
|
tc := tc
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
assert.ErrorIs(t, tc.serviceAccount.Validate(), tc.expect)
|
|
})
|
|
}
|
|
}
|