core/authorize: check for expired tokens (#4543)

* 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>
This commit is contained in:
Caleb Doxsey 2023-09-15 16:06:13 -06:00 committed by GitHub
parent e5a7b994b6
commit 23ea48815f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 127 additions and 1 deletions

View file

@ -0,0 +1,30 @@
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)
})
}
}