forked from TrueCloudLab/frostfs-s3-gw
[#673] Correct s3 error code
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
7626b6a04a
commit
091ec716d9
2 changed files with 18 additions and 1 deletions
|
@ -251,7 +251,7 @@ func (h *handler) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *http.Re
|
|||
if obj.Error != nil {
|
||||
errorObjects = append(errorObjects, formObjNameToLog(obj))
|
||||
code := "BadRequest"
|
||||
if s3err, ok := obj.Error.(errors.Error); ok {
|
||||
if s3err, ok := errors.TransformToS3Error(obj.Error).(errors.Error); ok {
|
||||
code = s3err.Code
|
||||
}
|
||||
response.Errors = append(response.Errors, DeleteError{
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/data"
|
||||
apierr "git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/errors"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/layer/encryption"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/layer/frostfs"
|
||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||
"github.com/pquerna/otp"
|
||||
|
@ -143,6 +144,22 @@ func TestDeleteMultipleObjectCheckUniqueness(t *testing.T) {
|
|||
require.Len(t, resp.DeletedObjects, 1)
|
||||
}
|
||||
|
||||
func TestDeleteMultipleObjectCheckS3Error(t *testing.T) {
|
||||
hc := prepareHandlerContext(t)
|
||||
|
||||
bktName, objName := "bucket", "object"
|
||||
createTestBucket(hc, bktName)
|
||||
|
||||
putObject(hc, bktName, objName)
|
||||
|
||||
hc.tp.SetObjectError(addrFromObject(hc.tp.Objects()[0]), frostfs.ErrAccessDenied)
|
||||
|
||||
resp := deleteObjects(t, hc, bktName, [][2]string{{objName, emptyVersion}})
|
||||
require.Empty(t, resp.DeletedObjects)
|
||||
require.Len(t, resp.Errors, 1)
|
||||
require.Equal(t, "AccessDenied", resp.Errors[0].Code)
|
||||
}
|
||||
|
||||
func TestDeleteObjectsError(t *testing.T) {
|
||||
hc := prepareHandlerContext(t)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue