[#XX] pool/tree: Fix handling access denied error
DCO / DCO (pull_request) Failing after 1m6s Details
Tests and linters / Tests (1.21) (pull_request) Successful in 1m16s Details
Tests and linters / Tests (1.20) (pull_request) Successful in 1m53s Details
Tests and linters / Lint (pull_request) Successful in 3m12s Details

Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
Denis Kirillov 2024-05-30 14:58:14 +03:00
parent c5c6272029
commit f1995db70a
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") {
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)

View File

@ -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)