[#293] pkg/eacl: Implement and use generator of Table

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-06-08 11:26:23 +03:00 committed by Alex Vanin
parent f406463c34
commit 72adf5f972
2 changed files with 14 additions and 4 deletions

View file

@ -6,6 +6,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg" "github.com/nspcc-dev/neofs-api-go/pkg"
"github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl" "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
eacltest "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl/test"
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test" cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
sessiontest "github.com/nspcc-dev/neofs-api-go/pkg/session/test" sessiontest "github.com/nspcc-dev/neofs-api-go/pkg/session/test"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -65,10 +66,7 @@ func TestTable_AddRecord(t *testing.T) {
} }
func TestRecordEncoding(t *testing.T) { func TestRecordEncoding(t *testing.T) {
tab := eacl.NewTable() tab := eacltest.Table()
tab.AddRecord(
eacl.CreateRecord(eacl.ActionDeny, eacl.OperationHead),
)
t.Run("binary", func(t *testing.T) { t.Run("binary", func(t *testing.T) {
data, err := tab.Marshal() data, err := tab.Marshal()

View file

@ -4,6 +4,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl" "github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test" cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
ownertest "github.com/nspcc-dev/neofs-api-go/pkg/owner/test" ownertest "github.com/nspcc-dev/neofs-api-go/pkg/owner/test"
sessiontest "github.com/nspcc-dev/neofs-api-go/pkg/session/test"
) )
// Target returns random eacl.Target. // Target returns random eacl.Target.
@ -31,3 +32,14 @@ func Record() *eacl.Record {
return x return x
} }
func Table() *eacl.Table {
x := eacl.NewTable()
x.SetCID(cidtest.Generate())
x.SetSessionToken(sessiontest.Generate())
x.AddRecord(Record())
x.AddRecord(Record())
return x
}