[#226] pool/tree: Fix handling access denied error

Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
Denis Kirillov 2024-05-30 14:58:14 +03:00
parent c5c6272029
commit 6a52487edd
2 changed files with 6 additions and 1 deletions

View file

@ -599,7 +599,7 @@ func handleError(msg string, err error) error {
} }
if strings.Contains(err.Error(), "not found") { if strings.Contains(err.Error(), "not found") {
return fmt.Errorf("%w: %s", ErrNodeNotFound, err.Error()) 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("%w: %s", ErrNodeAccessDenied, err.Error())
} }
return fmt.Errorf("%s: %w", msg, err) return fmt.Errorf("%s: %w", msg, err)

View file

@ -5,6 +5,7 @@ import (
"errors" "errors"
"testing" "testing"
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool"
grpcService "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool/tree/service" grpcService "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool/tree/service"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -68,6 +69,10 @@ func TestHandleError(t *testing.T) {
err: errors.New("something is denied by some acl rule"), err: errors.New("something is denied by some acl rule"),
expectedError: ErrNodeAccessDenied, expectedError: ErrNodeAccessDenied,
}, },
{
err: &apistatus.APEManagerAccessDenied{},
expectedError: ErrNodeAccessDenied,
},
} { } {
t.Run("", func(t *testing.T) { t.Run("", func(t *testing.T) {
err := handleError("err message", tc.err) err := handleError("err message", tc.err)