forked from TrueCloudLab/frostfs-api-go
Add stable marshal of acl table
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
6e42ba8d22
commit
ddbeaa93b3
2 changed files with 124 additions and 33 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/acl"
|
||||
grpc "github.com/nspcc-dev/neofs-api-go/v2/acl/grpc"
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
@ -120,3 +121,28 @@ func TestRecord_StableMarshal(t *testing.T) {
|
|||
require.Equal(t, recordFrom, recordTo)
|
||||
})
|
||||
}
|
||||
|
||||
func TestTable_StableMarshal(t *testing.T) {
|
||||
tableFrom := new(acl.Table)
|
||||
transport := new(grpc.EACLTable)
|
||||
|
||||
t.Run("non empty", func(t *testing.T) {
|
||||
cid := new(refs.ContainerID)
|
||||
cid.SetValue([]byte("Container ID"))
|
||||
|
||||
r1 := generateRecord(false)
|
||||
r2 := generateRecord(true)
|
||||
|
||||
tableFrom.SetContainerID(cid)
|
||||
tableFrom.SetRecords([]*acl.Record{r1, r2})
|
||||
|
||||
wire, err := tableFrom.StableMarshal(nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = transport.Unmarshal(wire)
|
||||
require.NoError(t, err)
|
||||
|
||||
tableTo := acl.TableFromGRPCMessage(transport)
|
||||
require.Equal(t, tableFrom, tableTo)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue