[#226] pool/tree: Fix handling access denied error
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
c5c6272029
commit
6a52487edd
2 changed files with 6 additions and 1 deletions
|
@ -599,7 +599,7 @@ func handleError(msg string, err error) error {
|
|||
}
|
||||
if strings.Contains(err.Error(), "not found") {
|
||||
return fmt.Errorf("%w: %s", ErrNodeNotFound, err.Error())
|
||||
} else if strings.Contains(err.Error(), "is denied by") {
|
||||
} else if strings.Contains(err.Error(), "denied") {
|
||||
return fmt.Errorf("%w: %s", ErrNodeAccessDenied, err.Error())
|
||||
}
|
||||
return fmt.Errorf("%s: %w", msg, err)
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"errors"
|
||||
"testing"
|
||||
|
||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool"
|
||||
grpcService "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool/tree/service"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -68,6 +69,10 @@ func TestHandleError(t *testing.T) {
|
|||
err: errors.New("something is denied by some acl rule"),
|
||||
expectedError: ErrNodeAccessDenied,
|
||||
},
|
||||
{
|
||||
err: &apistatus.APEManagerAccessDenied{},
|
||||
expectedError: ErrNodeAccessDenied,
|
||||
},
|
||||
} {
|
||||
t.Run("", func(t *testing.T) {
|
||||
err := handleError("err message", tc.err)
|
||||
|
|
Loading…
Reference in a new issue