mirror of
https://github.com/minio/minio.git
synced 2024-12-26 23:25:54 -05:00
Merge pull request #765 from harshavardhana/pr_out_add_corresponding_tests
This commit is contained in:
commit
e81f44f623
@ -88,6 +88,10 @@ func (api Minio) ListMultipartUploadsHandler(w http.ResponseWriter, req *http.Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
resources := getBucketMultipartResources(req.URL.Query())
|
resources := getBucketMultipartResources(req.URL.Query())
|
||||||
|
if resources.MaxUploads < 0 {
|
||||||
|
writeErrorResponse(w, req, InvalidMaxUploads, acceptsContentType, req.URL.Path)
|
||||||
|
return
|
||||||
|
}
|
||||||
if resources.MaxUploads == 0 {
|
if resources.MaxUploads == 0 {
|
||||||
resources.MaxUploads = maxObjectList
|
resources.MaxUploads = maxObjectList
|
||||||
}
|
}
|
||||||
@ -155,6 +159,10 @@ func (api Minio) ListObjectsHandler(w http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resources := getBucketResources(req.URL.Query())
|
resources := getBucketResources(req.URL.Query())
|
||||||
|
if resources.Maxkeys < 0 {
|
||||||
|
writeErrorResponse(w, req, InvalidMaxKeys, acceptsContentType, req.URL.Path)
|
||||||
|
return
|
||||||
|
}
|
||||||
if resources.Maxkeys == 0 {
|
if resources.Maxkeys == 0 {
|
||||||
resources.Maxkeys = maxObjectList
|
resources.Maxkeys = maxObjectList
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,10 @@ const (
|
|||||||
InvalidDigest
|
InvalidDigest
|
||||||
InvalidRange
|
InvalidRange
|
||||||
InvalidRequest
|
InvalidRequest
|
||||||
|
InvalidMaxKeys
|
||||||
|
InvalidMaxUploads
|
||||||
|
InvalidMaxParts
|
||||||
|
InvalidPartNumberMarker
|
||||||
MalformedXML
|
MalformedXML
|
||||||
MissingContentLength
|
MissingContentLength
|
||||||
MissingRequestBodyError
|
MissingRequestBodyError
|
||||||
@ -69,11 +73,31 @@ const (
|
|||||||
|
|
||||||
// Error codes, non exhaustive list - standard HTTP errors
|
// Error codes, non exhaustive list - standard HTTP errors
|
||||||
const (
|
const (
|
||||||
NotAcceptable = iota + 25
|
NotAcceptable = iota + 29
|
||||||
)
|
)
|
||||||
|
|
||||||
// Error code to Error structure map
|
// Error code to Error structure map
|
||||||
var errorCodeResponse = map[int]Error{
|
var errorCodeResponse = map[int]Error{
|
||||||
|
InvalidMaxUploads: {
|
||||||
|
Code: "InvalidArgument",
|
||||||
|
Description: "Argument maxUploads must be an integer between 0 and 2147483647",
|
||||||
|
HTTPStatusCode: http.StatusBadRequest,
|
||||||
|
},
|
||||||
|
InvalidMaxKeys: {
|
||||||
|
Code: "InvalidArgument",
|
||||||
|
Description: "Argument maxKeys must be an integer between 0 and 2147483647",
|
||||||
|
HTTPStatusCode: http.StatusBadRequest,
|
||||||
|
},
|
||||||
|
InvalidMaxParts: {
|
||||||
|
Code: "InvalidArgument",
|
||||||
|
Description: "Argument maxParts must be an integer between 1 and 10000",
|
||||||
|
HTTPStatusCode: http.StatusBadRequest,
|
||||||
|
},
|
||||||
|
InvalidPartNumberMarker: {
|
||||||
|
Code: "InvalidArgument",
|
||||||
|
Description: "Argument partNumberMarker must be an integer",
|
||||||
|
HTTPStatusCode: http.StatusBadRequest,
|
||||||
|
},
|
||||||
AccessDenied: {
|
AccessDenied: {
|
||||||
Code: "AccessDenied",
|
Code: "AccessDenied",
|
||||||
Description: "Access Denied",
|
Description: "Access Denied",
|
||||||
|
@ -473,6 +473,14 @@ func (api Minio) ListObjectPartsHandler(w http.ResponseWriter, req *http.Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
objectResourcesMetadata := getObjectResources(req.URL.Query())
|
objectResourcesMetadata := getObjectResources(req.URL.Query())
|
||||||
|
if objectResourcesMetadata.PartNumberMarker < 0 {
|
||||||
|
writeErrorResponse(w, req, InvalidPartNumberMarker, acceptsContentType, req.URL.Path)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if objectResourcesMetadata.MaxParts < 0 {
|
||||||
|
writeErrorResponse(w, req, InvalidMaxParts, acceptsContentType, req.URL.Path)
|
||||||
|
return
|
||||||
|
}
|
||||||
if objectResourcesMetadata.MaxParts == 0 {
|
if objectResourcesMetadata.MaxParts == 0 {
|
||||||
objectResourcesMetadata.MaxParts = maxPartsList
|
objectResourcesMetadata.MaxParts = maxPartsList
|
||||||
}
|
}
|
||||||
|
@ -548,6 +548,22 @@ func (s *MyAPIDonutCacheSuite) TestListObjectsHandlerErrors(c *C) {
|
|||||||
response, err = client.Do(request)
|
response, err = client.Do(request)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound)
|
verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound)
|
||||||
|
|
||||||
|
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objecthandlererrors", nil)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
request.Header.Add("x-amz-acl", "private")
|
||||||
|
|
||||||
|
client = http.Client{}
|
||||||
|
response, err = client.Do(request)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
|
request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/objecthandlererrors?max-keys=-2", nil)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
client = http.Client{}
|
||||||
|
response, err = client.Do(request)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
verifyError(c, response, "InvalidArgument", "Argument maxKeys must be an integer between 0 and 2147483647", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MyAPIDonutCacheSuite) TestPutBucketErrors(c *C) {
|
func (s *MyAPIDonutCacheSuite) TestPutBucketErrors(c *C) {
|
||||||
@ -787,6 +803,12 @@ func (s *MyAPIDonutCacheSuite) TestObjectMultipartList(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response3.StatusCode, Equals, http.StatusOK)
|
c.Assert(response3.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
|
request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/objectmultipartlist/object?max-parts=-2&uploadId="+uploadID, nil)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
|
response4, err := client.Do(request)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
verifyError(c, response4, "InvalidArgument", "Argument maxParts must be an integer between 1 and 10000", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MyAPIDonutCacheSuite) TestObjectMultipart(c *C) {
|
func (s *MyAPIDonutCacheSuite) TestObjectMultipart(c *C) {
|
||||||
|
@ -568,6 +568,22 @@ func (s *MyAPIDonutSuite) TestListObjectsHandlerErrors(c *C) {
|
|||||||
response, err = client.Do(request)
|
response, err = client.Do(request)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound)
|
verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound)
|
||||||
|
|
||||||
|
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/objecthandlererrors", nil)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
request.Header.Add("x-amz-acl", "private")
|
||||||
|
|
||||||
|
client = http.Client{}
|
||||||
|
response, err = client.Do(request)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
|
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/objecthandlererrors?max-keys=-2", nil)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
client = http.Client{}
|
||||||
|
response, err = client.Do(request)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
verifyError(c, response, "InvalidArgument", "Argument maxKeys must be an integer between 0 and 2147483647", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MyAPIDonutSuite) TestPutBucketErrors(c *C) {
|
func (s *MyAPIDonutSuite) TestPutBucketErrors(c *C) {
|
||||||
@ -807,6 +823,12 @@ func (s *MyAPIDonutSuite) TestObjectMultipartList(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response3.StatusCode, Equals, http.StatusOK)
|
c.Assert(response3.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
|
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/objectmultipartlist/object?max-parts=-2&uploadId="+uploadID, nil)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
|
response4, err := client.Do(request)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
verifyError(c, response4, "InvalidArgument", "Argument maxParts must be an integer between 1 and 10000", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MyAPIDonutSuite) TestObjectMultipart(c *C) {
|
func (s *MyAPIDonutSuite) TestObjectMultipart(c *C) {
|
||||||
|
@ -560,6 +560,22 @@ func (s *MyAPISignatureV4Suite) TestListObjectsHandlerErrors(c *C) {
|
|||||||
response, err = client.Do(request)
|
response, err = client.Do(request)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound)
|
verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound)
|
||||||
|
|
||||||
|
request, err = s.newRequest("PUT", testSignatureV4Server.URL+"/objecthandlererrors", 0, nil)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
request.Header.Add("x-amz-acl", "private")
|
||||||
|
|
||||||
|
client = http.Client{}
|
||||||
|
response, err = client.Do(request)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
|
request, err = http.NewRequest("GET", testSignatureV4Server.URL+"/objecthandlererrors?max-keys=-2", nil)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
client = http.Client{}
|
||||||
|
response, err = client.Do(request)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
verifyError(c, response, "InvalidArgument", "Argument maxKeys must be an integer between 0 and 2147483647", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MyAPISignatureV4Suite) TestPutBucketErrors(c *C) {
|
func (s *MyAPISignatureV4Suite) TestPutBucketErrors(c *C) {
|
||||||
@ -806,6 +822,12 @@ func (s *MyAPISignatureV4Suite) TestObjectMultipartList(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response3.StatusCode, Equals, http.StatusOK)
|
c.Assert(response3.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
|
request, err = http.NewRequest("GET", testSignatureV4Server.URL+"/objectmultipartlist/object?max-parts=-2&uploadId="+uploadID, nil)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
|
response4, err := client.Do(request)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
verifyError(c, response4, "InvalidArgument", "Argument maxParts must be an integer between 1 and 10000", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MyAPISignatureV4Suite) TestObjectMultipart(c *C) {
|
func (s *MyAPISignatureV4Suite) TestObjectMultipart(c *C) {
|
||||||
|
Loading…
Reference in New Issue
Block a user