protoutil: add NewAny method for deterministic serialization (#2462) (#2662)

This commit is contained in:
backport-actions-token[bot] 2021-10-05 15:41:32 -04:00 committed by GitHub
parent 46a1426925
commit 0f6cc036ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 90 additions and 148 deletions

View file

@ -15,16 +15,14 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/pomerium/pomerium/pkg/cryptutil"
"github.com/pomerium/pomerium/internal/testutil"
"github.com/pomerium/pomerium/pkg/cryptutil"
"github.com/pomerium/pomerium/pkg/grpc/databroker"
"github.com/pomerium/pomerium/pkg/grpc/session"
"github.com/pomerium/pomerium/pkg/protoutil"
)
type testSyncerHandler struct {
@ -58,10 +56,8 @@ func TestServer_Get(t *testing.T) {
s := new(session.Session)
s.Id = "1"
any, err := anypb.New(s)
assert.NoError(t, err)
_, err = srv.Put(context.Background(), &databroker.PutRequest{
any := protoutil.NewAny(s)
_, err := srv.Put(context.Background(), &databroker.PutRequest{
Record: &databroker.Record{
Type: any.TypeUrl,
Id: s.Id,
@ -92,10 +88,8 @@ func TestServer_Options(t *testing.T) {
s := new(session.Session)
s.Id = "1"
any, err := anypb.New(s)
assert.NoError(t, err)
_, err = srv.Put(context.Background(), &databroker.PutRequest{
any := protoutil.NewAny(s)
_, err := srv.Put(context.Background(), &databroker.PutRequest{
Record: &databroker.Record{
Type: any.TypeUrl,
Id: s.Id,
@ -143,10 +137,8 @@ func TestServer_Query(t *testing.T) {
s := new(session.Session)
s.Id = "1"
any, err := anypb.New(s)
assert.NoError(t, err)
_, err = srv.Put(context.Background(), &databroker.PutRequest{
any := protoutil.NewAny(s)
_, err := srv.Put(context.Background(), &databroker.PutRequest{
Record: &databroker.Record{
Type: any.TypeUrl,
Id: s.Id,
@ -166,10 +158,8 @@ func TestServer_Sync(t *testing.T) {
s := new(session.Session)
s.Id = "1"
any, err := anypb.New(s)
assert.NoError(t, err)
_, err = srv.Put(context.Background(), &databroker.PutRequest{
any := protoutil.NewAny(s)
_, err := srv.Put(context.Background(), &databroker.PutRequest{
Record: &databroker.Record{
Type: any.TypeUrl,
Id: s.Id,
@ -252,10 +242,8 @@ func TestServerInvalidStorage(t *testing.T) {
s := new(session.Session)
s.Id = "1"
any, err := anypb.New(s)
assert.NoError(t, err)
_, err = srv.Put(context.Background(), &databroker.PutRequest{
any := protoutil.NewAny(s)
_, err := srv.Put(context.Background(), &databroker.PutRequest{
Record: &databroker.Record{
Type: any.TypeUrl,
Id: s.Id,
@ -275,10 +263,8 @@ func TestServerRedis(t *testing.T) {
s := new(session.Session)
s.Id = "1"
any, err := anypb.New(s)
assert.NoError(t, err)
_, err = srv.Put(context.Background(), &databroker.PutRequest{
any := protoutil.NewAny(s)
_, err := srv.Put(context.Background(), &databroker.PutRequest{
Record: &databroker.Record{
Type: any.TypeUrl,
Id: s.Id,