mirror of
https://github.com/minio/minio.git
synced 2025-11-08 21:24:55 -05:00
Add full API tests, move storage/donut to donut, add disk tests as well
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
package api
|
||||
|
||||
import "github.com/minio/minio/pkg/storage/donut"
|
||||
import "github.com/minio/minio/pkg/donut"
|
||||
|
||||
// Operation container for individual operations read by Ticket Master
|
||||
type Operation struct {
|
||||
|
||||
@@ -20,8 +20,8 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/minio/minio/pkg/donut"
|
||||
"github.com/minio/minio/pkg/iodine"
|
||||
"github.com/minio/minio/pkg/storage/donut"
|
||||
"github.com/minio/minio/pkg/utils/log"
|
||||
)
|
||||
|
||||
@@ -83,6 +83,10 @@ func (api Minio) ListMultipartUploadsHandler(w http.ResponseWriter, req *http.Re
|
||||
}
|
||||
|
||||
acceptsContentType := getContentType(req)
|
||||
if !api.isValidOp(w, req, acceptsContentType) {
|
||||
return
|
||||
}
|
||||
|
||||
resources := getBucketMultipartResources(req.URL.Query())
|
||||
if resources.MaxUploads == 0 {
|
||||
resources.MaxUploads = maxObjectList
|
||||
@@ -132,7 +136,6 @@ func (api Minio) ListObjectsHandler(w http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
|
||||
acceptsContentType := getContentType(req)
|
||||
// verify if bucket allows this operation
|
||||
if !api.isValidOp(w, req, acceptsContentType) {
|
||||
return
|
||||
}
|
||||
@@ -160,6 +163,10 @@ func (api Minio) ListObjectsHandler(w http.ResponseWriter, req *http.Request) {
|
||||
setCommonHeaders(w, getContentTypeString(acceptsContentType), len(encodedSuccessResponse))
|
||||
// write body
|
||||
w.Write(encodedSuccessResponse)
|
||||
case donut.BucketNameInvalid:
|
||||
writeErrorResponse(w, req, InvalidBucketName, acceptsContentType, req.URL.Path)
|
||||
case donut.BucketNotFound:
|
||||
writeErrorResponse(w, req, NoSuchBucket, acceptsContentType, req.URL.Path)
|
||||
case donut.ObjectNotFound:
|
||||
writeErrorResponse(w, req, NoSuchKey, acceptsContentType, req.URL.Path)
|
||||
case donut.ObjectNameInvalid:
|
||||
|
||||
@@ -199,7 +199,7 @@ func getConfigFile() string {
|
||||
if err := os.MkdirAll(confPath, 0700); err != nil {
|
||||
return ""
|
||||
}
|
||||
return filepath.Join(confPath, "config.json")
|
||||
return filepath.Join(confPath, "users.json")
|
||||
}
|
||||
|
||||
// validate auth header handler ServeHTTP() wrapper
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/minio/minio/pkg/storage/donut"
|
||||
"github.com/minio/minio/pkg/donut"
|
||||
)
|
||||
|
||||
// No encoder interface exists, so we create one.
|
||||
|
||||
@@ -24,8 +24,8 @@ import (
|
||||
"encoding/xml"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/minio/minio/pkg/donut"
|
||||
"github.com/minio/minio/pkg/iodine"
|
||||
"github.com/minio/minio/pkg/storage/donut"
|
||||
"github.com/minio/minio/pkg/utils/log"
|
||||
)
|
||||
|
||||
@@ -48,8 +48,6 @@ func (api Minio) GetObjectHandler(w http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
|
||||
acceptsContentType := getContentType(req)
|
||||
|
||||
// verify if this operation is allowed
|
||||
if !api.isValidOp(w, req, acceptsContentType) {
|
||||
return
|
||||
}
|
||||
@@ -85,6 +83,10 @@ func (api Minio) GetObjectHandler(w http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
}
|
||||
}
|
||||
case donut.BucketNameInvalid:
|
||||
writeErrorResponse(w, req, InvalidBucketName, acceptsContentType, req.URL.Path)
|
||||
case donut.BucketNotFound:
|
||||
writeErrorResponse(w, req, NoSuchBucket, acceptsContentType, req.URL.Path)
|
||||
case donut.ObjectNotFound:
|
||||
writeErrorResponse(w, req, NoSuchKey, acceptsContentType, req.URL.Path)
|
||||
case donut.ObjectNameInvalid:
|
||||
@@ -109,8 +111,6 @@ func (api Minio) HeadObjectHandler(w http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
|
||||
acceptsContentType := getContentType(req)
|
||||
|
||||
// verify if this operation is allowed
|
||||
if !api.isValidOp(w, req, acceptsContentType) {
|
||||
return
|
||||
}
|
||||
@@ -125,6 +125,14 @@ func (api Minio) HeadObjectHandler(w http.ResponseWriter, req *http.Request) {
|
||||
case nil:
|
||||
setObjectHeaders(w, metadata)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
case donut.BucketNameInvalid:
|
||||
error := getErrorCode(InvalidBucketName)
|
||||
w.Header().Set("Server", "Minio")
|
||||
w.WriteHeader(error.HTTPStatusCode)
|
||||
case donut.BucketNotFound:
|
||||
error := getErrorCode(NoSuchBucket)
|
||||
w.Header().Set("Server", "Minio")
|
||||
w.WriteHeader(error.HTTPStatusCode)
|
||||
case donut.ObjectNotFound:
|
||||
error := getErrorCode(NoSuchKey)
|
||||
w.Header().Set("Server", "Minio")
|
||||
@@ -155,7 +163,6 @@ func (api Minio) PutObjectHandler(w http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
|
||||
acceptsContentType := getContentType(req)
|
||||
// verify if this operation is allowed
|
||||
if !api.isValidOp(w, req, acceptsContentType) {
|
||||
return
|
||||
}
|
||||
@@ -203,6 +210,10 @@ func (api Minio) PutObjectHandler(w http.ResponseWriter, req *http.Request) {
|
||||
case nil:
|
||||
w.Header().Set("ETag", metadata.MD5Sum)
|
||||
writeSuccessResponse(w, acceptsContentType)
|
||||
case donut.BucketNotFound:
|
||||
writeErrorResponse(w, req, NoSuchBucket, acceptsContentType, req.URL.Path)
|
||||
case donut.BucketNameInvalid:
|
||||
writeErrorResponse(w, req, InvalidBucketName, acceptsContentType, req.URL.Path)
|
||||
case donut.ObjectExists:
|
||||
writeErrorResponse(w, req, MethodNotAllowed, acceptsContentType, req.URL.Path)
|
||||
case donut.BadDigest:
|
||||
@@ -231,8 +242,6 @@ func (api Minio) NewMultipartUploadHandler(w http.ResponseWriter, req *http.Requ
|
||||
}
|
||||
|
||||
acceptsContentType := getContentType(req)
|
||||
|
||||
// handle ACL's here at bucket level
|
||||
if !api.isValidOp(w, req, acceptsContentType) {
|
||||
return
|
||||
}
|
||||
@@ -278,8 +287,6 @@ func (api Minio) PutObjectPartHandler(w http.ResponseWriter, req *http.Request)
|
||||
}
|
||||
|
||||
acceptsContentType := getContentType(req)
|
||||
|
||||
// handle ACL's here at bucket level
|
||||
if !api.isValidOp(w, req, acceptsContentType) {
|
||||
return
|
||||
}
|
||||
@@ -355,8 +362,6 @@ func (api Minio) AbortMultipartUploadHandler(w http.ResponseWriter, req *http.Re
|
||||
}
|
||||
|
||||
acceptsContentType := getContentType(req)
|
||||
|
||||
// handle ACL's here at bucket level
|
||||
if !api.isValidOp(w, req, acceptsContentType) {
|
||||
return
|
||||
}
|
||||
@@ -392,8 +397,6 @@ func (api Minio) ListObjectPartsHandler(w http.ResponseWriter, req *http.Request
|
||||
}
|
||||
|
||||
acceptsContentType := getContentType(req)
|
||||
|
||||
// handle ACL's here at bucket level
|
||||
if !api.isValidOp(w, req, acceptsContentType) {
|
||||
return
|
||||
}
|
||||
@@ -438,8 +441,6 @@ func (api Minio) CompleteMultipartUploadHandler(w http.ResponseWriter, req *http
|
||||
}
|
||||
|
||||
acceptsContentType := getContentType(req)
|
||||
|
||||
// handle ACL's here at bucket level
|
||||
if !api.isValidOp(w, req, acceptsContentType) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"github.com/minio/minio/pkg/storage/donut"
|
||||
"github.com/minio/minio/pkg/donut"
|
||||
)
|
||||
|
||||
// parse bucket url queries
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"net/http"
|
||||
"sort"
|
||||
|
||||
"github.com/minio/minio/pkg/storage/donut"
|
||||
"github.com/minio/minio/pkg/donut"
|
||||
)
|
||||
|
||||
// Reply date format
|
||||
|
||||
Reference in New Issue
Block a user