2022-12-20 08:38:58 +00:00
|
|
|
package frostfs
|
2022-04-21 08:49:56 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
2023-03-07 14:38:08 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/layer"
|
|
|
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
2022-04-21 08:49:56 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestErrorChecking(t *testing.T) {
|
|
|
|
reason := "some reason"
|
|
|
|
err := new(apistatus.ObjectAccessDenied)
|
|
|
|
err.WriteReason(reason)
|
|
|
|
|
|
|
|
var wrappedError error
|
|
|
|
|
|
|
|
if fetchedReason, ok := isErrAccessDenied(err); ok {
|
2022-06-06 11:09:09 +00:00
|
|
|
wrappedError = fmt.Errorf("%w: %s", layer.ErrAccessDenied, fetchedReason)
|
2022-04-21 08:49:56 +00:00
|
|
|
}
|
|
|
|
|
2022-06-06 11:09:09 +00:00
|
|
|
require.ErrorIs(t, wrappedError, layer.ErrAccessDenied)
|
2022-04-21 08:49:56 +00:00
|
|
|
require.Contains(t, wrappedError.Error(), reason)
|
|
|
|
}
|