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
master
Harshavardhana 10 years ago
commit 9d525ecadc
  1. 4
      pkg/server/api/object-handlers.go
  2. 19
      pkg/server/api_donut_cache_test.go
  3. 19
      pkg/server/api_donut_test.go
  4. 19
      pkg/server/api_signature_v4_test.go

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

@ -65,6 +65,25 @@ func (s *MyAPIDonutCacheSuite) TearDownSuite(c *C) {
testAPIDonutCacheServer.Close() 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) { func (s *MyAPIDonutCacheSuite) TestNonExistantBucket(c *C) {
request, err := http.NewRequest("HEAD", testAPIDonutCacheServer.URL+"/nonexistantbucket", nil) request, err := http.NewRequest("HEAD", testAPIDonutCacheServer.URL+"/nonexistantbucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)

@ -84,6 +84,25 @@ func (s *MyAPIDonutSuite) TearDownSuite(c *C) {
testAPIDonutServer.Close() 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) { func (s *MyAPIDonutSuite) TestNonExistantBucket(c *C) {
request, err := http.NewRequest("HEAD", testAPIDonutServer.URL+"/nonexistantbucket", nil) request, err := http.NewRequest("HEAD", testAPIDonutServer.URL+"/nonexistantbucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)

@ -92,6 +92,25 @@ func (s *MyAPISignatureV4Suite) TearDownSuite(c *C) {
testSignatureV4Server.Close() 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) { func (s *MyAPISignatureV4Suite) TestNonExistantBucket(c *C) {
request, err := s.newRequest("HEAD", testSignatureV4Server.URL+"/nonexistantbucket", 0, nil) request, err := s.newRequest("HEAD", testSignatureV4Server.URL+"/nonexistantbucket", 0, nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)

Loading…
Cancel
Save