mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 16:59:22 +02:00
This commit is contained in:
parent
46a1426925
commit
0f6cc036ae
20 changed files with 90 additions and 148 deletions
|
@ -13,7 +13,6 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/types/known/anypb"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
|
||||
"github.com/pomerium/pomerium/config"
|
||||
|
@ -23,6 +22,7 @@ import (
|
|||
"github.com/pomerium/pomerium/pkg/grpc/directory"
|
||||
"github.com/pomerium/pomerium/pkg/grpc/session"
|
||||
"github.com/pomerium/pomerium/pkg/grpc/user"
|
||||
"github.com/pomerium/pomerium/pkg/protoutil"
|
||||
)
|
||||
|
||||
func TestEvaluator(t *testing.T) {
|
||||
|
@ -480,7 +480,7 @@ func BenchmarkEvaluator_Evaluate(b *testing.B) {
|
|||
sessionID := uuid.New().String()
|
||||
lastSessionID = sessionID
|
||||
userID := uuid.New().String()
|
||||
data, _ := anypb.New(&session.Session{
|
||||
data := protoutil.NewAny(&session.Session{
|
||||
Version: fmt.Sprint(i),
|
||||
Id: sessionID,
|
||||
UserId: userID,
|
||||
|
@ -501,7 +501,7 @@ func BenchmarkEvaluator_Evaluate(b *testing.B) {
|
|||
Id: sessionID,
|
||||
Data: data,
|
||||
})
|
||||
data, _ = anypb.New(&user.User{
|
||||
data = protoutil.NewAny(&user.User{
|
||||
Version: fmt.Sprint(i),
|
||||
Id: userID,
|
||||
})
|
||||
|
@ -512,7 +512,7 @@ func BenchmarkEvaluator_Evaluate(b *testing.B) {
|
|||
Data: data,
|
||||
})
|
||||
|
||||
data, _ = anypb.New(&directory.User{
|
||||
data = protoutil.NewAny(&directory.User{
|
||||
Version: fmt.Sprint(i),
|
||||
Id: userID,
|
||||
GroupIds: []string{"1", "2", "3", "4"},
|
||||
|
@ -524,7 +524,7 @@ func BenchmarkEvaluator_Evaluate(b *testing.B) {
|
|||
Data: data,
|
||||
})
|
||||
|
||||
data, _ = anypb.New(&directory.Group{
|
||||
data = protoutil.NewAny(&directory.Group{
|
||||
Version: fmt.Sprint(i),
|
||||
Id: fmt.Sprint(i),
|
||||
})
|
||||
|
|
|
@ -15,13 +15,13 @@ import (
|
|||
"github.com/open-policy-agent/opa/storage/inmem"
|
||||
"github.com/open-policy-agent/opa/types"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/types/known/anypb"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
|
||||
"github.com/pomerium/pomerium/config"
|
||||
"github.com/pomerium/pomerium/internal/log"
|
||||
"github.com/pomerium/pomerium/pkg/cryptutil"
|
||||
"github.com/pomerium/pomerium/pkg/grpc/databroker"
|
||||
"github.com/pomerium/pomerium/pkg/protoutil"
|
||||
)
|
||||
|
||||
type dataBrokerData struct {
|
||||
|
@ -102,11 +102,7 @@ func NewStore() *Store {
|
|||
func NewStoreFromProtos(serverVersion uint64, msgs ...proto.Message) *Store {
|
||||
s := NewStore()
|
||||
for _, msg := range msgs {
|
||||
any, err := anypb.New(msg)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
any := protoutil.NewAny(msg)
|
||||
record := new(databroker.Record)
|
||||
record.ModifiedAt = timestamppb.Now()
|
||||
record.Version = cryptutil.NewRandomUInt64()
|
||||
|
|
|
@ -4,11 +4,11 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"google.golang.org/protobuf/types/known/anypb"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
|
||||
"github.com/pomerium/pomerium/pkg/grpc/databroker"
|
||||
"github.com/pomerium/pomerium/pkg/grpc/user"
|
||||
"github.com/pomerium/pomerium/pkg/protoutil"
|
||||
)
|
||||
|
||||
func TestStore(t *testing.T) {
|
||||
|
@ -20,7 +20,7 @@ func TestStore(t *testing.T) {
|
|||
Name: "name",
|
||||
Email: "name@example.com",
|
||||
}
|
||||
any, _ := anypb.New(u)
|
||||
any := protoutil.NewAny(u)
|
||||
s.UpdateRecord(0, &databroker.Record{
|
||||
Version: 1,
|
||||
Type: any.GetTypeUrl(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue