diff --git a/pkg/acl/eacl/filter.go b/pkg/acl/eacl/filter.go index 3be0bb5..03c093e 100644 --- a/pkg/acl/eacl/filter.go +++ b/pkg/acl/eacl/filter.go @@ -108,6 +108,12 @@ func (k filterKey) String() string { } // NewFilter creates, initializes and returns blank Filter instance. +// +// Defaults: +// - header type: HeaderTypeUnknown; +// - matcher: MatchUnknown; +// - key: ""; +// - value: "". func NewFilter() *Filter { return NewFilterFromV2(new(v2acl.HeaderFilter)) } diff --git a/pkg/acl/eacl/filter_test.go b/pkg/acl/eacl/filter_test.go index 7918042..9a471d0 100644 --- a/pkg/acl/eacl/filter_test.go +++ b/pkg/acl/eacl/filter_test.go @@ -3,6 +3,7 @@ package eacl import ( "testing" + "github.com/nspcc-dev/neofs-api-go/v2/acl" v2acl "github.com/nspcc-dev/neofs-api-go/v2/acl" "github.com/stretchr/testify/require" ) @@ -66,4 +67,22 @@ func TestFilter_ToV2(t *testing.T) { require.Nil(t, x.ToV2()) }) + + t.Run("default values", func(t *testing.T) { + filter := NewFilter() + + // check initial values + require.Empty(t, filter.Key()) + require.Empty(t, filter.Value()) + require.Equal(t, HeaderTypeUnknown, filter.From()) + require.Equal(t, MatchUnknown, filter.Matcher()) + + // convert to v2 message + filterV2 := filter.ToV2() + + require.Empty(t, filterV2.GetKey()) + require.Empty(t, filterV2.GetValue()) + require.Equal(t, acl.HeaderTypeUnknown, filterV2.GetHeaderType()) + require.Equal(t, acl.MatchTypeUnknown, filterV2.GetMatchType()) + }) }