diff --git a/go.mod b/go.mod index cd2adc1f9e..7012823f07 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220601120906-3bec6657f5c5 // indirect github.com/nspcc-dev/neofs-api-go/v2 v2.12.2 github.com/nspcc-dev/neofs-contract v0.15.1 - github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.4.0.20220607185339-031eac2f48f6 + github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.4.0.20220609064532-517d7a1e4a0f github.com/nspcc-dev/tzhash v1.5.2 github.com/panjf2000/ants/v2 v2.4.0 github.com/paulmach/orb v0.2.2 diff --git a/go.sum b/go.sum index 06c5614d13..6c1c756e50 100644 Binary files a/go.sum and b/go.sum differ diff --git a/pkg/services/object/acl/acl.go b/pkg/services/object/acl/acl.go index 39e6895dc3..6774f09b65 100644 --- a/pkg/services/object/acl/acl.go +++ b/pkg/services/object/acl/acl.go @@ -190,7 +190,7 @@ func (c *Checker) CheckEACL(msg interface{}, reqInfo v2.RequestInfo) error { return fmt.Errorf("can't parse headers: %w", err) } - action := c.validator.CalculateAction(new(eaclSDK.ValidationUnit). + action, _ := c.validator.CalculateAction(new(eaclSDK.ValidationUnit). WithRole(reqInfo.RequestRole()). WithOperation(reqInfo.Operation()). WithContainerID(&cnr). diff --git a/pkg/services/object/acl/eacl/v2/eacl_test.go b/pkg/services/object/acl/eacl/v2/eacl_test.go index 7eba649cb2..1105b3bdc2 100644 --- a/pkg/services/object/acl/eacl/v2/eacl_test.go +++ b/pkg/services/object/acl/eacl/v2/eacl_test.go @@ -120,21 +120,21 @@ func TestHeadRequest(t *testing.T) { validator := eaclSDK.NewValidator() - require.Equal(t, eaclSDK.ActionDeny, validator.CalculateAction(unit.WithHeaderSource(newSource(t)))) + checkAction(t, eaclSDK.ActionDeny, validator, unit.WithHeaderSource(newSource(t))) meta.SetXHeaders(nil) - require.Equal(t, eaclSDK.ActionAllow, validator.CalculateAction(unit.WithHeaderSource(newSource(t)))) + checkDefaultAction(t, validator, unit.WithHeaderSource(newSource(t))) meta.SetXHeaders(xHdrs) obj.SetAttributes() - require.Equal(t, eaclSDK.ActionAllow, validator.CalculateAction(unit.WithHeaderSource(newSource(t)))) + checkDefaultAction(t, validator, unit.WithHeaderSource(newSource(t))) lStorage.err = errors.New("any error") - require.Equal(t, eaclSDK.ActionAllow, validator.CalculateAction(unit.WithHeaderSource(newSource(t)))) + checkDefaultAction(t, validator, unit.WithHeaderSource(newSource(t))) r.SetAction(eaclSDK.ActionAllow) @@ -149,6 +149,17 @@ func TestHeadRequest(t *testing.T) { table.AddRecord(rID) unit.WithEACLTable(table) - - require.Equal(t, eaclSDK.ActionAllow, validator.CalculateAction(unit.WithHeaderSource(newSource(t)))) + checkDefaultAction(t, validator, unit.WithHeaderSource(newSource(t))) +} + +func checkAction(t *testing.T, expected eaclSDK.Action, v *eaclSDK.Validator, u *eaclSDK.ValidationUnit) { + actual, fromRule := v.CalculateAction(u) + require.True(t, fromRule) + require.Equal(t, expected, actual) +} + +func checkDefaultAction(t *testing.T, v *eaclSDK.Validator, u *eaclSDK.ValidationUnit) { + actual, fromRule := v.CalculateAction(u) + require.False(t, fromRule) + require.Equal(t, eaclSDK.ActionAllow, actual) }