|
|
|
@ -439,7 +439,7 @@ func TestWebHandlerRemoveObject(t *testing.T) { |
|
|
|
|
ExecObjectLayerTest(t, testRemoveObjectWebHandler) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// testRemoveObjectWebHandler - Test RemoveObject web handler
|
|
|
|
|
// testRemoveObjectWebHandler - Test RemoveObjectObject web handler
|
|
|
|
|
func testRemoveObjectWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler) { |
|
|
|
|
// Register the API end points with XL/FS object layer.
|
|
|
|
|
apiRouter := initTestWebRPCEndPoint(obj) |
|
|
|
@ -477,9 +477,9 @@ func testRemoveObjectWebHandler(obj ObjectLayer, instanceType string, t TestErrH |
|
|
|
|
t.Fatalf("Was not able to upload an object, %v", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
removeObjectRequest := RemoveObjectArgs{BucketName: bucketName, Objects: []string{"a/", "object"}} |
|
|
|
|
removeObjectReply := &WebGenericRep{} |
|
|
|
|
req, err := newTestWebRPCRequest("Web.RemoveObject", authorization, removeObjectRequest) |
|
|
|
|
removeRequest := RemoveObjectArgs{BucketName: bucketName, Objects: []string{"a/", "object"}} |
|
|
|
|
removeReply := &WebGenericRep{} |
|
|
|
|
req, err := newTestWebRPCRequest("Web.RemoveObject", authorization, removeRequest) |
|
|
|
|
if err != nil { |
|
|
|
|
t.Fatalf("Failed to create HTTP request: <ERROR> %v", err) |
|
|
|
|
} |
|
|
|
@ -487,14 +487,14 @@ func testRemoveObjectWebHandler(obj ObjectLayer, instanceType string, t TestErrH |
|
|
|
|
if rec.Code != http.StatusOK { |
|
|
|
|
t.Fatalf("Expected the response status to be 200, but instead found `%d`", rec.Code) |
|
|
|
|
} |
|
|
|
|
err = getTestWebRPCResponse(rec, &removeObjectReply) |
|
|
|
|
err = getTestWebRPCResponse(rec, &removeReply) |
|
|
|
|
if err != nil { |
|
|
|
|
t.Fatalf("Failed, %v", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
removeObjectRequest = RemoveObjectArgs{BucketName: bucketName, Objects: []string{"a/", "object"}} |
|
|
|
|
removeObjectReply = &WebGenericRep{} |
|
|
|
|
req, err = newTestWebRPCRequest("Web.RemoveObject", authorization, removeObjectRequest) |
|
|
|
|
removeRequest = RemoveObjectArgs{BucketName: bucketName, Objects: []string{"a/", "object"}} |
|
|
|
|
removeReply = &WebGenericRep{} |
|
|
|
|
req, err = newTestWebRPCRequest("Web.RemoveObject", authorization, removeRequest) |
|
|
|
|
if err != nil { |
|
|
|
|
t.Fatalf("Failed to create HTTP request: <ERROR> %v", err) |
|
|
|
|
} |
|
|
|
@ -502,10 +502,28 @@ func testRemoveObjectWebHandler(obj ObjectLayer, instanceType string, t TestErrH |
|
|
|
|
if rec.Code != http.StatusOK { |
|
|
|
|
t.Fatalf("Expected the response status to be 200, but instead found `%d`", rec.Code) |
|
|
|
|
} |
|
|
|
|
err = getTestWebRPCResponse(rec, &removeObjectReply) |
|
|
|
|
err = getTestWebRPCResponse(rec, &removeReply) |
|
|
|
|
if err != nil { |
|
|
|
|
t.Fatalf("Failed, %v", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
removeRequest = RemoveObjectArgs{BucketName: bucketName} |
|
|
|
|
removeReply = &WebGenericRep{} |
|
|
|
|
req, err = newTestWebRPCRequest("Web.RemoveObject", authorization, removeRequest) |
|
|
|
|
if err != nil { |
|
|
|
|
t.Fatalf("Failed to create HTTP request: <ERROR> %v", err) |
|
|
|
|
} |
|
|
|
|
apiRouter.ServeHTTP(rec, req) |
|
|
|
|
if rec.Code != http.StatusOK { |
|
|
|
|
t.Fatalf("Expected the response status to be 200, but instead found `%d`", rec.Code) |
|
|
|
|
} |
|
|
|
|
b, err := ioutil.ReadAll(rec.Body) |
|
|
|
|
if err != nil { |
|
|
|
|
t.Fatal(err) |
|
|
|
|
} |
|
|
|
|
if !bytes.Contains(b, []byte("Invalid arguments specified")) { |
|
|
|
|
t.Fatalf("Expected response wrong %s", string(b)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Wrapper for calling Generate Auth Handler
|
|
|
|
|