From 6a52487edd8d2d5f485e3e375b512a5e554470c4 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Thu, 30 May 2024 14:58:14 +0300 Subject: [PATCH] [#226] pool/tree: Fix handling access denied error Signed-off-by: Denis Kirillov --- pool/tree/pool.go | 2 +- pool/tree/pool_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pool/tree/pool.go b/pool/tree/pool.go index 28cc98b..2c55351 100644 --- a/pool/tree/pool.go +++ b/pool/tree/pool.go @@ -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) diff --git a/pool/tree/pool_test.go b/pool/tree/pool_test.go index f85b656..c2e50eb 100644 --- a/pool/tree/pool_test.go +++ b/pool/tree/pool_test.go @@ -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)