[#553] eacl: Fix bug with casting to ObjectAccessDenied error
All checks were successful
Build / Build Components (1.19) (pull_request) Successful in 2m3s
Build / Build Components (1.20) (pull_request) Successful in 1m51s
Tests and linters / Lint (pull_request) Successful in 1m46s
Tests and linters / Tests (1.20) (pull_request) Successful in 2m24s
Tests and linters / Staticcheck (pull_request) Successful in 2m24s
Vulncheck / Vulncheck (pull_request) Successful in 1m2s
Tests and linters / Tests (1.19) (pull_request) Successful in 12m11s
Tests and linters / Tests with -race (pull_request) Successful in 21m4s
All checks were successful
Build / Build Components (1.19) (pull_request) Successful in 2m3s
Build / Build Components (1.20) (pull_request) Successful in 1m51s
Tests and linters / Lint (pull_request) Successful in 1m46s
Tests and linters / Tests (1.20) (pull_request) Successful in 2m24s
Tests and linters / Staticcheck (pull_request) Successful in 2m24s
Vulncheck / Vulncheck (pull_request) Successful in 1m2s
Tests and linters / Tests (1.19) (pull_request) Successful in 12m11s
Tests and linters / Tests with -race (pull_request) Successful in 21m4s
Signed-off-by: Airat Arifullin a.arifullin@yadro.com
This commit is contained in:
parent
b8052c794e
commit
6e69410c17
2 changed files with 32 additions and 2 deletions
|
@ -25,14 +25,14 @@ const accessDeniedACLReasonFmt = "access to operation %s is denied by basic ACL
|
||||||
const accessDeniedEACLReasonFmt = "access to operation %s is denied by extended ACL check: %v"
|
const accessDeniedEACLReasonFmt = "access to operation %s is denied by extended ACL check: %v"
|
||||||
|
|
||||||
func basicACLErr(info RequestInfo) error {
|
func basicACLErr(info RequestInfo) error {
|
||||||
var errAccessDenied apistatus.ObjectAccessDenied
|
errAccessDenied := &apistatus.ObjectAccessDenied{}
|
||||||
errAccessDenied.WriteReason(fmt.Sprintf(accessDeniedACLReasonFmt, info.operation))
|
errAccessDenied.WriteReason(fmt.Sprintf(accessDeniedACLReasonFmt, info.operation))
|
||||||
|
|
||||||
return errAccessDenied
|
return errAccessDenied
|
||||||
}
|
}
|
||||||
|
|
||||||
func eACLErr(info RequestInfo, err error) error {
|
func eACLErr(info RequestInfo, err error) error {
|
||||||
var errAccessDenied apistatus.ObjectAccessDenied
|
errAccessDenied := &apistatus.ObjectAccessDenied{}
|
||||||
errAccessDenied.WriteReason(fmt.Sprintf(accessDeniedEACLReasonFmt, info.operation, err))
|
errAccessDenied.WriteReason(fmt.Sprintf(accessDeniedEACLReasonFmt, info.operation, err))
|
||||||
|
|
||||||
return errAccessDenied
|
return errAccessDenied
|
||||||
|
|
30
pkg/services/object/acl/v2/errors_test.go
Normal file
30
pkg/services/object/acl/v2/errors_test.go
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
package v2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestBasicACLErr(t *testing.T) {
|
||||||
|
var reqInfo RequestInfo
|
||||||
|
err := basicACLErr(reqInfo)
|
||||||
|
|
||||||
|
var errAccessDenied *apistatus.ObjectAccessDenied
|
||||||
|
|
||||||
|
require.ErrorAs(t, err, &errAccessDenied,
|
||||||
|
"basicACLErr must be able to be casted to apistatus.ObjectAccessDenied")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestEACLErr(t *testing.T) {
|
||||||
|
var reqInfo RequestInfo
|
||||||
|
testErr := errors.New("test-eacl")
|
||||||
|
err := eACLErr(reqInfo, testErr)
|
||||||
|
|
||||||
|
var errAccessDenied *apistatus.ObjectAccessDenied
|
||||||
|
|
||||||
|
require.ErrorAs(t, err, &errAccessDenied,
|
||||||
|
"eACLErr must be able to be casted to apistatus.ObjectAccessDenied")
|
||||||
|
}
|
Loading…
Reference in a new issue