diff --git a/pkg/acl/eacl/target.go b/pkg/acl/eacl/target.go index 8574e48a..22a2af69 100644 --- a/pkg/acl/eacl/target.go +++ b/pkg/acl/eacl/target.go @@ -124,6 +124,10 @@ func (t *Target) ToV2() *v2acl.Target { } // NewTarget creates, initializes and returns blank Target instance. +// +// Defaults: +// - role: RoleUnknown; +// - keys: nil. func NewTarget() *Target { return NewTargetFromV2(new(v2acl.Target)) } diff --git a/pkg/acl/eacl/target_test.go b/pkg/acl/eacl/target_test.go index 6612e3ac..5fd0e705 100644 --- a/pkg/acl/eacl/target_test.go +++ b/pkg/acl/eacl/target_test.go @@ -4,6 +4,7 @@ import ( "crypto/ecdsa" "testing" + "github.com/nspcc-dev/neofs-api-go/v2/acl" v2acl "github.com/nspcc-dev/neofs-api-go/v2/acl" crypto "github.com/nspcc-dev/neofs-crypto" "github.com/nspcc-dev/neofs-crypto/test" @@ -68,4 +69,18 @@ func TestTarget_ToV2(t *testing.T) { require.Nil(t, x.ToV2()) }) + + t.Run("default values", func(t *testing.T) { + target := NewTarget() + + // check initial values + require.Equal(t, RoleUnknown, target.Role()) + require.Nil(t, target.BinaryKeys()) + + // convert to v2 message + targetV2 := target.ToV2() + + require.Equal(t, acl.RoleUnknown, targetV2.GetRole()) + require.Nil(t, targetV2.GetKeys()) + }) }