|
|
|
@ -650,6 +650,17 @@ func testAPIDeleteMultipleObjectsHandler(obj ObjectLayer, instanceType, bucketNa |
|
|
|
|
|
|
|
|
|
return objectIdentifierList |
|
|
|
|
} |
|
|
|
|
getDeleteErrorList := func(objects []ObjectIdentifier) (deleteErrorList []DeleteError) { |
|
|
|
|
for _, obj := range objects { |
|
|
|
|
deleteErrorList = append(deleteErrorList, DeleteError{ |
|
|
|
|
Code: errorCodeResponse[ErrAccessDenied].Code, |
|
|
|
|
Message: errorCodeResponse[ErrAccessDenied].Description, |
|
|
|
|
Key: obj.ObjectName, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return deleteErrorList |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
requestList := []DeleteObjectsRequest{ |
|
|
|
|
{Quiet: false, Objects: getObjectIdentifierList(objectNames[:5])}, |
|
|
|
@ -670,6 +681,10 @@ func testAPIDeleteMultipleObjectsHandler(obj ObjectLayer, instanceType, bucketNa |
|
|
|
|
errorResponse := generateMultiDeleteResponse(requestList[1].Quiet, requestList[1].Objects, nil) |
|
|
|
|
encodedErrorResponse := encodeResponse(errorResponse) |
|
|
|
|
|
|
|
|
|
anonRequest := encodeResponse(requestList[0]) |
|
|
|
|
anonResponse := generateMultiDeleteResponse(requestList[0].Quiet, nil, getDeleteErrorList(requestList[0].Objects)) |
|
|
|
|
encodedAnonResponse := encodeResponse(anonResponse) |
|
|
|
|
|
|
|
|
|
testCases := []struct { |
|
|
|
|
bucket string |
|
|
|
|
objects []byte |
|
|
|
@ -718,15 +733,32 @@ func testAPIDeleteMultipleObjectsHandler(obj ObjectLayer, instanceType, bucketNa |
|
|
|
|
expectedContent: encodedErrorResponse, |
|
|
|
|
expectedRespStatus: http.StatusOK, |
|
|
|
|
}, |
|
|
|
|
// Test case - 5.
|
|
|
|
|
// Anonymous user access denied response
|
|
|
|
|
// Currently anonymous users cannot delete multiple objects in Minio server
|
|
|
|
|
{ |
|
|
|
|
bucket: bucketName, |
|
|
|
|
objects: anonRequest, |
|
|
|
|
accessKey: "", |
|
|
|
|
secretKey: "", |
|
|
|
|
expectedContent: encodedAnonResponse, |
|
|
|
|
expectedRespStatus: http.StatusOK, |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for i, testCase := range testCases { |
|
|
|
|
var req *http.Request |
|
|
|
|
var actualContent []byte |
|
|
|
|
|
|
|
|
|
// Indicating that all parts are uploaded and initiating completeMultipartUpload.
|
|
|
|
|
// Generate a signed or anonymous request based on the testCase
|
|
|
|
|
if testCase.accessKey != "" { |
|
|
|
|
req, err = newTestSignedRequestV4("POST", getDeleteMultipleObjectsURL("", bucketName), |
|
|
|
|
int64(len(testCase.objects)), bytes.NewReader(testCase.objects), testCase.accessKey, testCase.secretKey) |
|
|
|
|
} else { |
|
|
|
|
req, err = newTestRequest("POST", getDeleteMultipleObjectsURL("", bucketName), |
|
|
|
|
int64(len(testCase.objects)), bytes.NewReader(testCase.objects)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
t.Fatalf("Failed to create HTTP request for DeleteMultipleObjects: <ERROR> %v", err) |
|
|
|
|
} |
|
|
|
@ -753,8 +785,6 @@ func testAPIDeleteMultipleObjectsHandler(obj ObjectLayer, instanceType, bucketNa |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Currently anonymous user cannot delete multiple objects in Minio server, hence no test case is required.
|
|
|
|
|
|
|
|
|
|
// HTTP request to test the case of `objectLayer` being set to `nil`.
|
|
|
|
|
// There is no need to use an existing bucket or valid input for creating the request,
|
|
|
|
|
// since the `objectLayer==nil` check is performed before any other checks inside the handlers.
|
|
|
|
|