Merge pull request #763 from harshavardhana/pr_out_method_not_allowed_is_right_response_for_delete_operations_and_add_tests

Method not allowed is right response for DELETE() operations and add tests
This commit is contained in:
Harshavardhana 2015-07-16 21:36:05 +00:00
commit 9d525ecadc
4 changed files with 59 additions and 2 deletions

View File

@ -580,12 +580,12 @@ func (api Minio) CompleteMultipartUploadHandler(w http.ResponseWriter, req *http
// DeleteBucketHandler - Delete bucket
func (api Minio) DeleteBucketHandler(w http.ResponseWriter, req *http.Request) {
error := getErrorCode(NotImplemented)
error := getErrorCode(MethodNotAllowed)
w.WriteHeader(error.HTTPStatusCode)
}
// DeleteObjectHandler - Delete object
func (api Minio) DeleteObjectHandler(w http.ResponseWriter, req *http.Request) {
error := getErrorCode(NotImplemented)
error := getErrorCode(MethodNotAllowed)
w.WriteHeader(error.HTTPStatusCode)
}

View File

@ -65,6 +65,25 @@ func (s *MyAPIDonutCacheSuite) TearDownSuite(c *C) {
testAPIDonutCacheServer.Close()
}
func (s *MyAPIDonutCacheSuite) TestDeleteBucket(c *C) {
request, err := http.NewRequest("DELETE", testAPIDonutCacheServer.URL+"/mybucket", nil)
c.Assert(err, IsNil)
client := &http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusMethodNotAllowed)
}
func (s *MyAPIDonutCacheSuite) TestDeleteObject(c *C) {
request, err := http.NewRequest("DELETE", testAPIDonutCacheServer.URL+"/mybucket/myobject", nil)
c.Assert(err, IsNil)
client := &http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusMethodNotAllowed)
}
func (s *MyAPIDonutCacheSuite) TestNonExistantBucket(c *C) {
request, err := http.NewRequest("HEAD", testAPIDonutCacheServer.URL+"/nonexistantbucket", nil)
c.Assert(err, IsNil)

View File

@ -84,6 +84,25 @@ func (s *MyAPIDonutSuite) TearDownSuite(c *C) {
testAPIDonutServer.Close()
}
func (s *MyAPIDonutSuite) TestDeleteBucket(c *C) {
request, err := http.NewRequest("DELETE", testAPIDonutServer.URL+"/mybucket", nil)
c.Assert(err, IsNil)
client := &http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusMethodNotAllowed)
}
func (s *MyAPIDonutSuite) TestDeleteObject(c *C) {
request, err := http.NewRequest("DELETE", testAPIDonutServer.URL+"/mybucket/myobject", nil)
c.Assert(err, IsNil)
client := &http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusMethodNotAllowed)
}
func (s *MyAPIDonutSuite) TestNonExistantBucket(c *C) {
request, err := http.NewRequest("HEAD", testAPIDonutServer.URL+"/nonexistantbucket", nil)
c.Assert(err, IsNil)

View File

@ -92,6 +92,25 @@ func (s *MyAPISignatureV4Suite) TearDownSuite(c *C) {
testSignatureV4Server.Close()
}
func (s *MyAPISignatureV4Suite) TestDeleteBucket(c *C) {
request, err := http.NewRequest("DELETE", testSignatureV4Server.URL+"/mybucket", nil)
c.Assert(err, IsNil)
client := &http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusMethodNotAllowed)
}
func (s *MyAPISignatureV4Suite) TestDeleteObject(c *C) {
request, err := http.NewRequest("DELETE", testSignatureV4Server.URL+"/mybucket/myobject", nil)
c.Assert(err, IsNil)
client := &http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusMethodNotAllowed)
}
func (s *MyAPISignatureV4Suite) TestNonExistantBucket(c *C) {
request, err := s.newRequest("HEAD", testSignatureV4Server.URL+"/nonexistantbucket", 0, nil)
c.Assert(err, IsNil)