From 86a887f9d4d4773aae2407d867a1577ac1c5ec45 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 16 Jul 2015 17:32:33 -0700 Subject: [PATCH] Add corresponding tests --- pkg/server/api/errors.go | 2 +- pkg/server/api_donut_cache_test.go | 22 ++++++++++++++++++++++ pkg/server/api_donut_test.go | 22 ++++++++++++++++++++++ pkg/server/api_signature_v4_test.go | 22 ++++++++++++++++++++++ 4 files changed, 67 insertions(+), 1 deletion(-) diff --git a/pkg/server/api/errors.go b/pkg/server/api/errors.go index 1058c2937..e0003cbf9 100644 --- a/pkg/server/api/errors.go +++ b/pkg/server/api/errors.go @@ -90,7 +90,7 @@ var errorCodeResponse = map[int]Error{ }, InvalidMaxParts: { Code: "InvalidArgument", - Description: "Argument maxParts must be an integer between 1 and 10000 ", + Description: "Argument maxParts must be an integer between 1 and 10000", HTTPStatusCode: http.StatusBadRequest, }, InvalidPartNumberMarker: { diff --git a/pkg/server/api_donut_cache_test.go b/pkg/server/api_donut_cache_test.go index a0afb142d..a7ec5f4f9 100644 --- a/pkg/server/api_donut_cache_test.go +++ b/pkg/server/api_donut_cache_test.go @@ -548,6 +548,22 @@ func (s *MyAPIDonutCacheSuite) TestListObjectsHandlerErrors(c *C) { response, err = client.Do(request) c.Assert(err, IsNil) 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) { @@ -787,6 +803,12 @@ func (s *MyAPIDonutCacheSuite) TestObjectMultipartList(c *C) { c.Assert(err, IsNil) 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) { diff --git a/pkg/server/api_donut_test.go b/pkg/server/api_donut_test.go index 23b370c19..6d7e9dfa0 100644 --- a/pkg/server/api_donut_test.go +++ b/pkg/server/api_donut_test.go @@ -568,6 +568,22 @@ func (s *MyAPIDonutSuite) TestListObjectsHandlerErrors(c *C) { response, err = client.Do(request) c.Assert(err, IsNil) 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) { @@ -807,6 +823,12 @@ func (s *MyAPIDonutSuite) TestObjectMultipartList(c *C) { c.Assert(err, IsNil) 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) { diff --git a/pkg/server/api_signature_v4_test.go b/pkg/server/api_signature_v4_test.go index 8c7b4463e..45fe75db8 100644 --- a/pkg/server/api_signature_v4_test.go +++ b/pkg/server/api_signature_v4_test.go @@ -560,6 +560,22 @@ func (s *MyAPISignatureV4Suite) TestListObjectsHandlerErrors(c *C) { response, err = client.Do(request) c.Assert(err, IsNil) 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) { @@ -806,6 +822,12 @@ func (s *MyAPISignatureV4Suite) TestObjectMultipartList(c *C) { c.Assert(err, IsNil) 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) {