mirror of
https://github.com/minio/minio.git
synced 2025-01-27 06:33:18 -05:00
Implement x-amz-acl tests
This commit is contained in:
parent
107e077ec0
commit
2c1455af1b
@ -453,6 +453,7 @@ func (s *MySuite) TestPutBucket(c *C) {
|
||||
typedDriver.On("CreateBucket", "bucket").Return(nil).Once()
|
||||
request, err := http.NewRequest("PUT", testServer.URL+"/bucket", bytes.NewBufferString(""))
|
||||
c.Assert(err, IsNil)
|
||||
request.Header.Add("x-amz-acl", "private")
|
||||
|
||||
client := http.Client{}
|
||||
response, err := client.Do(request)
|
||||
@ -499,6 +500,7 @@ func (s *MySuite) TestPutObject(c *C) {
|
||||
typedDriver.On("CreateBucket", "bucket").Return(nil).Once()
|
||||
request, err := http.NewRequest("PUT", testServer.URL+"/bucket", bytes.NewBufferString(""))
|
||||
c.Assert(err, IsNil)
|
||||
request.Header.Add("x-amz-acl", "private")
|
||||
|
||||
client := http.Client{}
|
||||
response, err := client.Do(request)
|
||||
@ -970,6 +972,8 @@ func (s *MySuite) TestPutBucketErrors(c *C) {
|
||||
typedDriver.On("CreateBucket", "foo").Return(drivers.BucketNameInvalid{}).Once()
|
||||
request, err := http.NewRequest("PUT", testServer.URL+"/foo", bytes.NewBufferString(""))
|
||||
c.Assert(err, IsNil)
|
||||
request.Header.Add("x-amz-acl", "private")
|
||||
|
||||
response, err := client.Do(request)
|
||||
c.Assert(err, IsNil)
|
||||
verifyError(c, response, "InvalidBucketName", "The specified bucket is not valid.", http.StatusBadRequest)
|
||||
@ -977,6 +981,8 @@ func (s *MySuite) TestPutBucketErrors(c *C) {
|
||||
typedDriver.On("CreateBucket", "foo").Return(drivers.BucketExists{}).Once()
|
||||
request, err = http.NewRequest("PUT", testServer.URL+"/foo", bytes.NewBufferString(""))
|
||||
c.Assert(err, IsNil)
|
||||
request.Header.Add("x-amz-acl", "private")
|
||||
|
||||
response, err = client.Do(request)
|
||||
c.Assert(err, IsNil)
|
||||
verifyError(c, response, "BucketAlreadyExists", "The requested bucket name is not available.", http.StatusConflict)
|
||||
@ -984,9 +990,20 @@ func (s *MySuite) TestPutBucketErrors(c *C) {
|
||||
typedDriver.On("CreateBucket", "foo").Return(drivers.BackendCorrupted{}).Once()
|
||||
request, err = http.NewRequest("PUT", testServer.URL+"/foo", bytes.NewBufferString(""))
|
||||
c.Assert(err, IsNil)
|
||||
request.Header.Add("x-amz-acl", "private")
|
||||
|
||||
response, err = client.Do(request)
|
||||
c.Assert(err, IsNil)
|
||||
verifyError(c, response, "InternalError", "We encountered an internal error, please try again.", http.StatusInternalServerError)
|
||||
|
||||
typedDriver.On("CreateBucket", "foo").Return(nil).Once()
|
||||
request, err = http.NewRequest("PUT", testServer.URL+"/foo", bytes.NewBufferString(""))
|
||||
c.Assert(err, IsNil)
|
||||
request.Header.Add("x-amz-acl", "unknown")
|
||||
|
||||
response, err = client.Do(request)
|
||||
c.Assert(err, IsNil)
|
||||
verifyError(c, response, "NotImplemented", "A header you provided implies functionality that is not implemented.", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
func (s *MySuite) TestGetObjectErrors(c *C) {
|
||||
|
@ -16,10 +16,7 @@
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
import "net/http"
|
||||
|
||||
type contentType int
|
||||
|
||||
@ -32,14 +29,17 @@ const (
|
||||
// Get content type requested from 'Accept' header
|
||||
func getContentType(req *http.Request) contentType {
|
||||
acceptHeader := req.Header.Get("Accept")
|
||||
if acceptHeader != "" {
|
||||
switch {
|
||||
case strings.HasPrefix(acceptHeader, "application/json"):
|
||||
case acceptHeader == "application/json":
|
||||
return jsonContentType
|
||||
case strings.HasPrefix(acceptHeader, "application/xml"):
|
||||
case acceptHeader == "application/xml":
|
||||
return xmlContentType
|
||||
default:
|
||||
return unknownContentType
|
||||
}
|
||||
}
|
||||
return xmlContentType
|
||||
}
|
||||
|
||||
// Content type to human readable string
|
||||
|
Loading…
x
Reference in New Issue
Block a user