PutObject handler gets initial support for signature v4, working

This commit is contained in:
Harshavardhana 2015-07-09 14:42:04 -07:00
parent 4f29dc9134
commit 89c1215194
12 changed files with 196 additions and 324 deletions

View File

@ -156,7 +156,7 @@ func (s *MyDonutSuite) TestCreateMultipleBucketsAndList(c *C) {
// test object create without bucket // test object create without bucket
func (s *MyDonutSuite) TestNewObjectFailsWithoutBucket(c *C) { func (s *MyDonutSuite) TestNewObjectFailsWithoutBucket(c *C) {
_, err := dd.CreateObject("unknown", "obj", "", 0, nil, nil) _, err := dd.CreateObject("unknown", "obj", "", 0, nil, nil, nil)
c.Assert(err, Not(IsNil)) c.Assert(err, Not(IsNil))
} }
@ -171,7 +171,7 @@ func (s *MyDonutSuite) TestNewObjectMetadata(c *C) {
err := dd.MakeBucket("foo6", "private") err := dd.MakeBucket("foo6", "private")
c.Assert(err, IsNil) c.Assert(err, IsNil)
objectMetadata, err := dd.CreateObject("foo6", "obj", expectedMd5Sum, int64(len(data)), reader, map[string]string{"contentType": "application/json"}) objectMetadata, err := dd.CreateObject("foo6", "obj", expectedMd5Sum, int64(len(data)), reader, map[string]string{"contentType": "application/json"}, nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(objectMetadata.MD5Sum, Equals, hex.EncodeToString(hasher.Sum(nil))) c.Assert(objectMetadata.MD5Sum, Equals, hex.EncodeToString(hasher.Sum(nil)))
c.Assert(objectMetadata.Metadata["contentType"], Equals, "application/json") c.Assert(objectMetadata.Metadata["contentType"], Equals, "application/json")
@ -179,7 +179,7 @@ func (s *MyDonutSuite) TestNewObjectMetadata(c *C) {
// test create object fails without name // test create object fails without name
func (s *MyDonutSuite) TestNewObjectFailsWithEmptyName(c *C) { func (s *MyDonutSuite) TestNewObjectFailsWithEmptyName(c *C) {
_, err := dd.CreateObject("foo", "", "", 0, nil, nil) _, err := dd.CreateObject("foo", "", "", 0, nil, nil, nil)
c.Assert(err, Not(IsNil)) c.Assert(err, Not(IsNil))
} }
@ -195,7 +195,7 @@ func (s *MyDonutSuite) TestNewObjectCanBeWritten(c *C) {
expectedMd5Sum := base64.StdEncoding.EncodeToString(hasher.Sum(nil)) expectedMd5Sum := base64.StdEncoding.EncodeToString(hasher.Sum(nil))
reader := ioutil.NopCloser(bytes.NewReader([]byte(data))) reader := ioutil.NopCloser(bytes.NewReader([]byte(data)))
actualMetadata, err := dd.CreateObject("foo", "obj", expectedMd5Sum, int64(len(data)), reader, map[string]string{"contentType": "application/octet-stream"}) actualMetadata, err := dd.CreateObject("foo", "obj", expectedMd5Sum, int64(len(data)), reader, map[string]string{"contentType": "application/octet-stream"}, nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(actualMetadata.MD5Sum, Equals, hex.EncodeToString(hasher.Sum(nil))) c.Assert(actualMetadata.MD5Sum, Equals, hex.EncodeToString(hasher.Sum(nil)))
@ -217,11 +217,11 @@ func (s *MyDonutSuite) TestMultipleNewObjects(c *C) {
one := ioutil.NopCloser(bytes.NewReader([]byte("one"))) one := ioutil.NopCloser(bytes.NewReader([]byte("one")))
_, err := dd.CreateObject("foo5", "obj1", "", int64(len("one")), one, nil) _, err := dd.CreateObject("foo5", "obj1", "", int64(len("one")), one, nil, nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
two := ioutil.NopCloser(bytes.NewReader([]byte("two"))) two := ioutil.NopCloser(bytes.NewReader([]byte("two")))
_, err = dd.CreateObject("foo5", "obj2", "", int64(len("two")), two, nil) _, err = dd.CreateObject("foo5", "obj2", "", int64(len("two")), two, nil, nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
var buffer1 bytes.Buffer var buffer1 bytes.Buffer
@ -270,7 +270,7 @@ func (s *MyDonutSuite) TestMultipleNewObjects(c *C) {
c.Assert(objectsMetadata[1].Object, Equals, "obj2") c.Assert(objectsMetadata[1].Object, Equals, "obj2")
three := ioutil.NopCloser(bytes.NewReader([]byte("three"))) three := ioutil.NopCloser(bytes.NewReader([]byte("three")))
_, err = dd.CreateObject("foo5", "obj3", "", int64(len("three")), three, nil) _, err = dd.CreateObject("foo5", "obj3", "", int64(len("three")), three, nil, nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
var buffer bytes.Buffer var buffer bytes.Buffer

View File

@ -25,7 +25,6 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"log" "log"
"net/http"
"runtime/debug" "runtime/debug"
"sort" "sort"
"strconv" "strconv"
@ -33,6 +32,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/minio/minio/pkg/crypto/sha256"
"github.com/minio/minio/pkg/donut/cache/data" "github.com/minio/minio/pkg/donut/cache/data"
"github.com/minio/minio/pkg/donut/cache/metadata" "github.com/minio/minio/pkg/donut/cache/metadata"
"github.com/minio/minio/pkg/iodine" "github.com/minio/minio/pkg/iodine"
@ -55,7 +55,6 @@ type Config struct {
// API - local variables // API - local variables
type API struct { type API struct {
config *Config config *Config
req *http.Request
lock *sync.Mutex lock *sync.Mutex
objects *data.Cache objects *data.Cache
multiPartObjects map[string]*data.Cache multiPartObjects map[string]*data.Cache
@ -124,11 +123,6 @@ func New() (Interface, error) {
return a, nil return a, nil
} }
// SetRequest API for setting request header
func (donut API) SetRequest(req *http.Request) {
donut.req = req
}
// GetObject - GET object from cache buffer // GetObject - GET object from cache buffer
func (donut API) GetObject(w io.Writer, bucket string, object string) (int64, error) { func (donut API) GetObject(w io.Writer, bucket string, object string) (int64, error) {
donut.lock.Lock() donut.lock.Lock()
@ -296,12 +290,12 @@ func isMD5SumEqual(expectedMD5Sum, actualMD5Sum string) error {
} }
// CreateObject - create an object // CreateObject - create an object
func (donut API) CreateObject(bucket, key, expectedMD5Sum string, size int64, data io.Reader, metadata map[string]string) (ObjectMetadata, error) { func (donut API) CreateObject(bucket, key, expectedMD5Sum string, size int64, data io.Reader, metadata map[string]string, signature *Signature) (ObjectMetadata, error) {
donut.lock.Lock() donut.lock.Lock()
defer donut.lock.Unlock() defer donut.lock.Unlock()
contentType := metadata["contentType"] contentType := metadata["contentType"]
objectMetadata, err := donut.createObject(bucket, key, contentType, expectedMD5Sum, size, data) objectMetadata, err := donut.createObject(bucket, key, contentType, expectedMD5Sum, size, data, signature)
// free // free
debug.FreeOSMemory() debug.FreeOSMemory()
@ -309,7 +303,7 @@ func (donut API) CreateObject(bucket, key, expectedMD5Sum string, size int64, da
} }
// createObject - PUT object to cache buffer // createObject - PUT object to cache buffer
func (donut API) createObject(bucket, key, contentType, expectedMD5Sum string, size int64, data io.Reader) (ObjectMetadata, error) { func (donut API) createObject(bucket, key, contentType, expectedMD5Sum string, size int64, data io.Reader, signature *Signature) (ObjectMetadata, error) {
if len(donut.config.NodeDiskMap) == 0 { if len(donut.config.NodeDiskMap) == 0 {
if size > int64(donut.config.MaxSize) { if size > int64(donut.config.MaxSize) {
generic := GenericObjectError{Bucket: bucket, Object: key} generic := GenericObjectError{Bucket: bucket, Object: key}
@ -369,6 +363,7 @@ func (donut API) createObject(bucket, key, contentType, expectedMD5Sum string, s
} }
// calculate md5 // calculate md5
hash := md5.New() hash := md5.New()
sha256hash := sha256.New()
var err error var err error
var totalLength int64 var totalLength int64
@ -382,6 +377,7 @@ func (donut API) createObject(bucket, key, contentType, expectedMD5Sum string, s
break break
} }
hash.Write(byteBuffer[0:length]) hash.Write(byteBuffer[0:length])
sha256hash.Write(byteBuffer[0:length])
ok := donut.objects.Append(objectKey, byteBuffer[0:length]) ok := donut.objects.Append(objectKey, byteBuffer[0:length])
if !ok { if !ok {
return ObjectMetadata{}, iodine.New(InternalError{}, nil) return ObjectMetadata{}, iodine.New(InternalError{}, nil)
@ -405,6 +401,15 @@ func (donut API) createObject(bucket, key, contentType, expectedMD5Sum string, s
return ObjectMetadata{}, iodine.New(BadDigest{}, nil) return ObjectMetadata{}, iodine.New(BadDigest{}, nil)
} }
} }
if signature != nil {
ok, err := signature.DoesSignatureMatch(hex.EncodeToString(sha256hash.Sum(nil)))
if err != nil {
return ObjectMetadata{}, iodine.New(err, nil)
}
if !ok {
return ObjectMetadata{}, iodine.New(SignatureDoesNotMatch{}, nil)
}
}
m := make(map[string]string) m := make(map[string]string)
m["contentType"] = contentType m["contentType"] = contentType

View File

@ -131,7 +131,7 @@ func (s *MyCacheSuite) TestCreateMultipleBucketsAndList(c *C) {
// test object create without bucket // test object create without bucket
func (s *MyCacheSuite) TestNewObjectFailsWithoutBucket(c *C) { func (s *MyCacheSuite) TestNewObjectFailsWithoutBucket(c *C) {
_, err := dc.CreateObject("unknown", "obj", "", 0, nil, nil) _, err := dc.CreateObject("unknown", "obj", "", 0, nil, nil, nil)
c.Assert(err, Not(IsNil)) c.Assert(err, Not(IsNil))
} }
@ -146,7 +146,7 @@ func (s *MyCacheSuite) TestNewObjectMetadata(c *C) {
err := dc.MakeBucket("foo6", "private") err := dc.MakeBucket("foo6", "private")
c.Assert(err, IsNil) c.Assert(err, IsNil)
objectMetadata, err := dc.CreateObject("foo6", "obj", expectedMd5Sum, int64(len(data)), reader, map[string]string{"contentType": "application/json"}) objectMetadata, err := dc.CreateObject("foo6", "obj", expectedMd5Sum, int64(len(data)), reader, map[string]string{"contentType": "application/json"}, nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(objectMetadata.MD5Sum, Equals, hex.EncodeToString(hasher.Sum(nil))) c.Assert(objectMetadata.MD5Sum, Equals, hex.EncodeToString(hasher.Sum(nil)))
c.Assert(objectMetadata.Metadata["contentType"], Equals, "application/json") c.Assert(objectMetadata.Metadata["contentType"], Equals, "application/json")
@ -154,7 +154,7 @@ func (s *MyCacheSuite) TestNewObjectMetadata(c *C) {
// test create object fails without name // test create object fails without name
func (s *MyCacheSuite) TestNewObjectFailsWithEmptyName(c *C) { func (s *MyCacheSuite) TestNewObjectFailsWithEmptyName(c *C) {
_, err := dc.CreateObject("foo", "", "", 0, nil, nil) _, err := dc.CreateObject("foo", "", "", 0, nil, nil, nil)
c.Assert(err, Not(IsNil)) c.Assert(err, Not(IsNil))
} }
@ -170,7 +170,7 @@ func (s *MyCacheSuite) TestNewObjectCanBeWritten(c *C) {
expectedMd5Sum := base64.StdEncoding.EncodeToString(hasher.Sum(nil)) expectedMd5Sum := base64.StdEncoding.EncodeToString(hasher.Sum(nil))
reader := ioutil.NopCloser(bytes.NewReader([]byte(data))) reader := ioutil.NopCloser(bytes.NewReader([]byte(data)))
actualMetadata, err := dc.CreateObject("foo", "obj", expectedMd5Sum, int64(len(data)), reader, map[string]string{"contentType": "application/octet-stream"}) actualMetadata, err := dc.CreateObject("foo", "obj", expectedMd5Sum, int64(len(data)), reader, map[string]string{"contentType": "application/octet-stream"}, nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(actualMetadata.MD5Sum, Equals, hex.EncodeToString(hasher.Sum(nil))) c.Assert(actualMetadata.MD5Sum, Equals, hex.EncodeToString(hasher.Sum(nil)))
@ -192,11 +192,11 @@ func (s *MyCacheSuite) TestMultipleNewObjects(c *C) {
one := ioutil.NopCloser(bytes.NewReader([]byte("one"))) one := ioutil.NopCloser(bytes.NewReader([]byte("one")))
_, err := dc.CreateObject("foo5", "obj1", "", int64(len("one")), one, nil) _, err := dc.CreateObject("foo5", "obj1", "", int64(len("one")), one, nil, nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
two := ioutil.NopCloser(bytes.NewReader([]byte("two"))) two := ioutil.NopCloser(bytes.NewReader([]byte("two")))
_, err = dc.CreateObject("foo5", "obj2", "", int64(len("two")), two, nil) _, err = dc.CreateObject("foo5", "obj2", "", int64(len("two")), two, nil, nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
var buffer1 bytes.Buffer var buffer1 bytes.Buffer
@ -245,7 +245,7 @@ func (s *MyCacheSuite) TestMultipleNewObjects(c *C) {
c.Assert(objectsMetadata[1].Object, Equals, "obj2") c.Assert(objectsMetadata[1].Object, Equals, "obj2")
three := ioutil.NopCloser(bytes.NewReader([]byte("three"))) three := ioutil.NopCloser(bytes.NewReader([]byte("three")))
_, err = dc.CreateObject("foo5", "obj3", "", int64(len("three")), three, nil) _, err = dc.CreateObject("foo5", "obj3", "", int64(len("three")), three, nil, nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
var buffer bytes.Buffer var buffer bytes.Buffer

View File

@ -41,7 +41,8 @@ type ObjectStorage interface {
GetObject(w io.Writer, bucket, object string) (int64, error) GetObject(w io.Writer, bucket, object string) (int64, error)
GetPartialObject(w io.Writer, bucket, object string, start, length int64) (int64, error) GetPartialObject(w io.Writer, bucket, object string, start, length int64) (int64, error)
GetObjectMetadata(bucket, object string) (ObjectMetadata, error) GetObjectMetadata(bucket, object string) (ObjectMetadata, error)
CreateObject(bucket, object, expectedMD5Sum string, size int64, reader io.Reader, metadata map[string]string) (ObjectMetadata, error) // bucket, object, expectedMD5Sum, size, reader, metadata, signature
CreateObject(string, string, string, int64, io.Reader, map[string]string, *Signature) (ObjectMetadata, error)
Multipart Multipart
} }

View File

@ -255,7 +255,7 @@ func (donut API) CompleteMultipartUpload(bucket, key, uploadID string, parts map
// this is needed for final verification inside CreateObject, do not convert this to hex // this is needed for final verification inside CreateObject, do not convert this to hex
md5sum := base64.StdEncoding.EncodeToString(md5sumSlice[:]) md5sum := base64.StdEncoding.EncodeToString(md5sumSlice[:])
donut.lock.Unlock() donut.lock.Unlock()
objectMetadata, err := donut.CreateObject(bucket, key, md5sum, size, &fullObject, nil) objectMetadata, err := donut.CreateObject(bucket, key, md5sum, size, &fullObject, nil, nil)
if err != nil { if err != nil {
// No need to call internal cleanup functions here, caller will call AbortMultipartUpload() // No need to call internal cleanup functions here, caller will call AbortMultipartUpload()
// which would in-turn cleanup properly in accordance with S3 Spec // which would in-turn cleanup properly in accordance with S3 Spec

View File

@ -21,7 +21,6 @@ import (
"crypto/hmac" "crypto/hmac"
"encoding/hex" "encoding/hex"
"errors" "errors"
"io"
"net/http" "net/http"
"regexp" "regexp"
"sort" "sort"
@ -29,30 +28,30 @@ import (
"time" "time"
"unicode/utf8" "unicode/utf8"
"github.com/minio/minio/pkg/auth"
"github.com/minio/minio/pkg/crypto/sha256" "github.com/minio/minio/pkg/crypto/sha256"
"github.com/minio/minio/pkg/iodine" "github.com/minio/minio/pkg/iodine"
) )
// request - a http request // Signature - local variables
type request struct { type Signature struct {
receivedReq *http.Request AccessKeyID string
calculatedReq *http.Request SecretAccessKey string
user *auth.User AuthHeader string
body io.Reader Request *http.Request
} }
const ( const (
authHeader = "AWS4-HMAC-SHA256" authHeaderPrefix = "AWS4-HMAC-SHA256"
iso8601Format = "20060102T150405Z" iso8601Format = "20060102T150405Z"
yyyymmdd = "20060102" yyyymmdd = "20060102"
) )
var ignoredHeaders = map[string]bool{ var ignoredHeaders = map[string]bool{
"Authorization": true, "Authorization": true,
"Content-Type": true, "Content-Type": true,
"Content-Length": true, "Accept-Encoding": true,
"User-Agent": true, "Content-Length": true,
"User-Agent": true,
} }
// sumHMAC calculate hmac between two input byte array // sumHMAC calculate hmac between two input byte array
@ -101,38 +100,11 @@ func urlEncodeName(name string) (string, error) {
return encodedName, nil return encodedName, nil
} }
// newSignV4Request - populate a new signature v4 request
func newSignV4Request(user *auth.User, req *http.Request, body io.Reader) (*request, error) {
// save for subsequent use
r := new(request)
r.user = user
r.body = body
r.receivedReq = req
r.calculatedReq = req
return r, nil
}
// getHashedPayload get the hexadecimal value of the SHA256 hash of the request payload
func (r *request) getHashedPayload() string {
hash := func() string {
switch {
case r.body == nil:
return hex.EncodeToString(sha256.Sum256([]byte{}))
default:
sum256Bytes, _ := sha256.Sum(r.body)
return hex.EncodeToString(sum256Bytes)
}
}
hashedPayload := hash()
r.calculatedReq.Header.Set("x-amz-content-sha256", hashedPayload)
return hashedPayload
}
// getCanonicalHeaders generate a list of request headers with their values // getCanonicalHeaders generate a list of request headers with their values
func (r *request) getCanonicalHeaders() string { func (r *Signature) getCanonicalHeaders() string {
var headers []string var headers []string
vals := make(map[string][]string) vals := make(map[string][]string)
for k, vv := range r.calculatedReq.Header { for k, vv := range r.Request.Header {
if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok { if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok {
continue // ignored header continue // ignored header
} }
@ -148,7 +120,7 @@ func (r *request) getCanonicalHeaders() string {
buf.WriteByte(':') buf.WriteByte(':')
switch { switch {
case k == "host": case k == "host":
buf.WriteString(r.calculatedReq.URL.Host) buf.WriteString(r.Request.Host)
fallthrough fallthrough
default: default:
for idx, v := range vals[k] { for idx, v := range vals[k] {
@ -164,9 +136,9 @@ func (r *request) getCanonicalHeaders() string {
} }
// getSignedHeaders generate a string i.e alphabetically sorted, semicolon-separated list of lowercase request header names // getSignedHeaders generate a string i.e alphabetically sorted, semicolon-separated list of lowercase request header names
func (r *request) getSignedHeaders() string { func (r *Signature) getSignedHeaders() string {
var headers []string var headers []string
for k := range r.calculatedReq.Header { for k := range r.Request.Header {
if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok { if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok {
continue // ignored header continue // ignored header
} }
@ -187,24 +159,24 @@ func (r *request) getSignedHeaders() string {
// <SignedHeaders>\n // <SignedHeaders>\n
// <HashedPayload> // <HashedPayload>
// //
func (r *request) getCanonicalRequest(hashedPayload string) string { func (r *Signature) getCanonicalRequest() string {
r.calculatedReq.URL.RawQuery = strings.Replace(r.calculatedReq.URL.Query().Encode(), "+", "%20", -1) r.Request.URL.RawQuery = strings.Replace(r.Request.URL.Query().Encode(), "+", "%20", -1)
encodedPath, _ := urlEncodeName(r.calculatedReq.URL.Path) encodedPath, _ := urlEncodeName(r.Request.URL.Path)
// convert any space strings back to "+" // convert any space strings back to "+"
encodedPath = strings.Replace(encodedPath, "+", "%20", -1) encodedPath = strings.Replace(encodedPath, "+", "%20", -1)
canonicalRequest := strings.Join([]string{ canonicalRequest := strings.Join([]string{
r.calculatedReq.Method, r.Request.Method,
encodedPath, encodedPath,
r.calculatedReq.URL.RawQuery, r.Request.URL.RawQuery,
r.getCanonicalHeaders(), r.getCanonicalHeaders(),
r.getSignedHeaders(), r.getSignedHeaders(),
hashedPayload, r.Request.Header.Get("x-amz-content-sha256"),
}, "\n") }, "\n")
return canonicalRequest return canonicalRequest
} }
// getScope generate a string of a specific date, an AWS region, and a service // getScope generate a string of a specific date, an AWS region, and a service
func (r *request) getScope(t time.Time) string { func (r *Signature) getScope(t time.Time) string {
scope := strings.Join([]string{ scope := strings.Join([]string{
t.Format(yyyymmdd), t.Format(yyyymmdd),
"milkyway", "milkyway",
@ -215,16 +187,16 @@ func (r *request) getScope(t time.Time) string {
} }
// getStringToSign a string based on selected query values // getStringToSign a string based on selected query values
func (r *request) getStringToSign(canonicalRequest string, t time.Time) string { func (r *Signature) getStringToSign(canonicalRequest string, t time.Time) string {
stringToSign := authHeader + "\n" + t.Format(iso8601Format) + "\n" stringToSign := authHeaderPrefix + "\n" + t.Format(iso8601Format) + "\n"
stringToSign = stringToSign + r.getScope(t) + "\n" stringToSign = stringToSign + r.getScope(t) + "\n"
stringToSign = stringToSign + hex.EncodeToString(sha256.Sum256([]byte(canonicalRequest))) stringToSign = stringToSign + hex.EncodeToString(sha256.Sum256([]byte(canonicalRequest)))
return stringToSign return stringToSign
} }
// getSigningKey hmac seed to calculate final signature // getSigningKey hmac seed to calculate final signature
func (r *request) getSigningKey(t time.Time) []byte { func (r *Signature) getSigningKey(t time.Time) []byte {
secret := r.user.SecretAccessKey secret := r.SecretAccessKey
date := sumHMAC([]byte("AWS4"+secret), []byte(t.Format(yyyymmdd))) date := sumHMAC([]byte("AWS4"+secret), []byte(t.Format(yyyymmdd)))
region := sumHMAC(date, []byte("milkyway")) region := sumHMAC(date, []byte("milkyway"))
service := sumHMAC(region, []byte("s3")) service := sumHMAC(region, []byte("s3"))
@ -233,26 +205,29 @@ func (r *request) getSigningKey(t time.Time) []byte {
} }
// getSignature final signature in hexadecimal form // getSignature final signature in hexadecimal form
func (r *request) getSignature(signingKey []byte, stringToSign string) string { func (r *Signature) getSignature(signingKey []byte, stringToSign string) string {
return hex.EncodeToString(sumHMAC(signingKey, []byte(stringToSign))) return hex.EncodeToString(sumHMAC(signingKey, []byte(stringToSign)))
} }
// SignV4 the request before Do(), in accordance with - http://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html // DoesSignatureMatch - Verify authorization header with calculated header in accordance with - http://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html
func (r *request) SignV4() (string, error) { // returns true if matches, false other wise if error is not nil then it is always false
func (r *Signature) DoesSignatureMatch(hashedPayload string) (bool, error) {
// set new calulated payload
r.Request.Header.Set("x-amz-content-sha256", hashedPayload)
// Add date if not present // Add date if not present
var date string var date string
if date = r.calculatedReq.Header.Get("x-amz-date"); date == "" { if date = r.Request.Header.Get("x-amz-date"); date == "" {
if date = r.calculatedReq.Header.Get("Date"); date == "" { if date = r.Request.Header.Get("Date"); date == "" {
return "", iodine.New(MissingDateHeader{}, nil) return false, iodine.New(MissingDateHeader{}, nil)
} }
} }
t, err := time.Parse(iso8601Format, date) t, err := time.Parse(iso8601Format, date)
if err != nil { if err != nil {
return "", iodine.New(err, nil) return false, iodine.New(err, nil)
} }
hashedPayload := r.getHashedPayload()
signedHeaders := r.getSignedHeaders() signedHeaders := r.getSignedHeaders()
canonicalRequest := r.getCanonicalRequest(hashedPayload) canonicalRequest := r.getCanonicalRequest()
scope := r.getScope(t) scope := r.getScope(t)
stringToSign := r.getStringToSign(canonicalRequest, t) stringToSign := r.getStringToSign(canonicalRequest, t)
signingKey := r.getSigningKey(t) signingKey := r.getSigningKey(t)
@ -260,10 +235,13 @@ func (r *request) SignV4() (string, error) {
// final Authorization header // final Authorization header
parts := []string{ parts := []string{
authHeader + " Credential=" + r.user.AccessKeyID + "/" + scope, authHeaderPrefix + " Credential=" + r.AccessKeyID + "/" + scope,
"SignedHeaders=" + signedHeaders, "SignedHeaders=" + signedHeaders,
"Signature=" + signature, "Signature=" + signature,
} }
auth := strings.Join(parts, ", ") newAuthHeader := strings.Join(parts, ", ")
return auth, nil if newAuthHeader != r.AuthHeader {
return false, nil
}
return true, nil
} }

View File

@ -42,7 +42,7 @@ func (api Minio) isValidOp(w http.ResponseWriter, req *http.Request, acceptsCont
return false return false
} }
case nil: case nil:
if _, err := stripAuth(req); err != nil { if _, err := StripAccessKeyID(req.Header.Get("Authorization")); err != nil {
if bucketMetadata.ACL.IsPrivate() { if bucketMetadata.ACL.IsPrivate() {
return true return true
//uncomment this when we have webcli //uncomment this when we have webcli
@ -194,7 +194,7 @@ func (api Minio) ListBucketsHandler(w http.ResponseWriter, req *http.Request) {
acceptsContentType := getContentType(req) acceptsContentType := getContentType(req)
// uncomment this when we have webcli // uncomment this when we have webcli
// without access key credentials one cannot list buckets // without access key credentials one cannot list buckets
// if _, err := stripAuth(req); err != nil { // if _, err := StripAccessKeyID(req); err != nil {
// writeErrorResponse(w, req, AccessDenied, acceptsContentType, req.URL.Path) // writeErrorResponse(w, req, AccessDenied, acceptsContentType, req.URL.Path)
// return // return
// } // }
@ -231,7 +231,7 @@ func (api Minio) PutBucketHandler(w http.ResponseWriter, req *http.Request) {
acceptsContentType := getContentType(req) acceptsContentType := getContentType(req)
// uncomment this when we have webcli // uncomment this when we have webcli
// without access key credentials one cannot create a bucket // without access key credentials one cannot create a bucket
// if _, err := stripAuth(req); err != nil { // if _, err := StripAccessKeyID(req); err != nil {
// writeErrorResponse(w, req, AccessDenied, acceptsContentType, req.URL.Path) // writeErrorResponse(w, req, AccessDenied, acceptsContentType, req.URL.Path)
// return // return
// } // }

View File

@ -19,7 +19,6 @@ package api
import ( import (
"errors" "errors"
"net/http" "net/http"
"strings"
"time" "time"
"github.com/minio/minio/pkg/auth" "github.com/minio/minio/pkg/auth"
@ -41,64 +40,12 @@ type resourceHandler struct {
handler http.Handler handler http.Handler
} }
type authHeader struct {
prefix string
credential string
signedheaders string
signature string
accessKey string
}
const ( const (
iso8601Format = "20060102T150405Z" iso8601Format = "20060102T150405Z"
) )
const (
authHeaderPrefix = "AWS4-HMAC-SHA256"
)
// strip auth from authorization header
func stripAuth(r *http.Request) (*authHeader, error) {
ah := r.Header.Get("Authorization")
if ah == "" {
return nil, errors.New("Missing auth header")
}
a := new(authHeader)
authFields := strings.Split(ah, ",")
if len(authFields) != 3 {
return nil, errors.New("Missing fields in Auth header")
}
authPrefixFields := strings.Fields(authFields[0])
if len(authPrefixFields) != 2 {
return nil, errors.New("Missing fields in Auth header")
}
if authPrefixFields[0] != authHeaderPrefix {
return nil, errors.New("Missing fields is Auth header")
}
credentials := strings.Split(authPrefixFields[1], "=")
if len(credentials) != 2 {
return nil, errors.New("Missing fields in Auth header")
}
signedheaders := strings.Split(authFields[1], "=")
if len(signedheaders) != 2 {
return nil, errors.New("Missing fields in Auth header")
}
signature := strings.Split(authFields[2], "=")
if len(signature) != 2 {
return nil, errors.New("Missing fields in Auth header")
}
a.credential = credentials[1]
a.signedheaders = signedheaders[1]
a.signature = signature[1]
a.accessKey = strings.Split(a.credential, "/")[0]
if !auth.IsValidAccessKey(a.accessKey) {
return nil, errors.New("Invalid access key")
}
return a, nil
}
func parseDate(req *http.Request) (time.Time, error) { func parseDate(req *http.Request) (time.Time, error) {
amzDate := req.Header.Get("X-Amz-Date") amzDate := req.Header.Get("x-amz-date")
switch { switch {
case amzDate != "": case amzDate != "":
if _, err := time.Parse(time.RFC1123, amzDate); err == nil { if _, err := time.Parse(time.RFC1123, amzDate); err == nil {
@ -150,7 +97,7 @@ func (h timeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
acceptsContentType := getContentType(r) acceptsContentType := getContentType(r)
// Verify if date headers are set, if not reject the request // Verify if date headers are set, if not reject the request
if r.Header.Get("Authorization") != "" { if r.Header.Get("Authorization") != "" {
if r.Header.Get("X-Amz-Date") == "" && r.Header.Get("Date") == "" { if r.Header.Get("x-amz-date") == "" && r.Header.Get("Date") == "" {
// there is no way to knowing if this is a valid request, could be a attack reject such clients // there is no way to knowing if this is a valid request, could be a attack reject such clients
writeErrorResponse(w, r, RequestTimeTooSkewed, acceptsContentType, r.URL.Path) writeErrorResponse(w, r, RequestTimeTooSkewed, acceptsContentType, r.URL.Path)
return return
@ -181,20 +128,20 @@ func ValidateAuthHeaderHandler(h http.Handler) http.Handler {
// validate auth header handler ServeHTTP() wrapper // validate auth header handler ServeHTTP() wrapper
func (h validateAuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (h validateAuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
acceptsContentType := getContentType(r) acceptsContentType := getContentType(r)
ah, err := stripAuth(r) accessKeyID, err := StripAccessKeyID(r.Header.Get("Authorization"))
switch err.(type) { switch err.(type) {
case nil: case nil:
// load auth config
authConfig, err := auth.LoadConfig() authConfig, err := auth.LoadConfig()
if err != nil { if err != nil {
writeErrorResponse(w, r, InternalError, acceptsContentType, r.URL.Path) writeErrorResponse(w, r, InternalError, acceptsContentType, r.URL.Path)
return return
} }
_, ok := authConfig.Users[ah.accessKey] // Access key not found
if !ok { if _, ok := authConfig.Users[accessKeyID]; !ok {
writeErrorResponse(w, r, AccessDenied, acceptsContentType, r.URL.Path) writeErrorResponse(w, r, InvalidAccessKeyID, acceptsContentType, r.URL.Path)
return return
} }
// Success
h.handler.ServeHTTP(w, r) h.handler.ServeHTTP(w, r)
default: default:
// control reaches here, we should just send the request up the stack - internally // control reaches here, we should just send the request up the stack - internally

View File

@ -205,7 +205,18 @@ func (api Minio) PutObjectHandler(w http.ResponseWriter, req *http.Request) {
return return
} }
metadata, err := api.Donut.CreateObject(bucket, object, md5, sizeInt64, req.Body, nil) var signature *donut.Signature
if _, ok := req.Header["Authorization"]; ok {
// Init signature V4 verification
var err error
signature, err = InitSignatureV4(req)
if err != nil {
writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path)
return
}
}
metadata, err := api.Donut.CreateObject(bucket, object, md5, sizeInt64, req.Body, nil, signature)
switch iodine.ToError(err).(type) { switch iodine.ToError(err).(type) {
case nil: case nil:
w.Header().Set("ETag", metadata.MD5Sum) w.Header().Set("ETag", metadata.MD5Sum)
@ -218,6 +229,10 @@ func (api Minio) PutObjectHandler(w http.ResponseWriter, req *http.Request) {
writeErrorResponse(w, req, MethodNotAllowed, acceptsContentType, req.URL.Path) writeErrorResponse(w, req, MethodNotAllowed, acceptsContentType, req.URL.Path)
case donut.BadDigest: case donut.BadDigest:
writeErrorResponse(w, req, BadDigest, acceptsContentType, req.URL.Path) writeErrorResponse(w, req, BadDigest, acceptsContentType, req.URL.Path)
case donut.MissingDateHeader:
writeErrorResponse(w, req, RequestTimeTooSkewed, acceptsContentType, req.URL.Path)
case donut.SignatureDoesNotMatch:
writeErrorResponse(w, req, SignatureDoesNotMatch, acceptsContentType, req.URL.Path)
case donut.IncompleteBody: case donut.IncompleteBody:
writeErrorResponse(w, req, IncompleteBody, acceptsContentType, req.URL.Path) writeErrorResponse(w, req, IncompleteBody, acceptsContentType, req.URL.Path)
case donut.EntityTooLarge: case donut.EntityTooLarge:

View File

@ -0,0 +1,85 @@
/*
* Minimalist Object Storage, (C) 2015 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package api
import (
"errors"
"net/http"
"strings"
"github.com/minio/minio/pkg/auth"
"github.com/minio/minio/pkg/donut"
"github.com/minio/minio/pkg/iodine"
)
const (
authHeaderPrefix = "AWS4-HMAC-SHA256"
)
// StripAccessKeyID - strip only access key id from auth header
func StripAccessKeyID(ah string) (string, error) {
if ah == "" {
return "", errors.New("Missing auth header")
}
authFields := strings.Split(ah, ",")
if len(authFields) != 3 {
return "", errors.New("Missing fields in Auth header")
}
authPrefixFields := strings.Fields(authFields[0])
if len(authPrefixFields) != 2 {
return "", errors.New("Missing fields in Auth header")
}
if authPrefixFields[0] != authHeaderPrefix {
return "", errors.New("Missing fields is Auth header")
}
credentials := strings.Split(authPrefixFields[1], "=")
if len(credentials) != 2 {
return "", errors.New("Missing fields in Auth header")
}
if len(strings.Split(authFields[1], "=")) != 2 {
return "", errors.New("Missing fields in Auth header")
}
if len(strings.Split(authFields[2], "=")) != 2 {
return "", errors.New("Missing fields in Auth header")
}
accessKeyID := strings.Split(credentials[1], "/")[0]
if !auth.IsValidAccessKey(accessKeyID) {
return "", errors.New("Invalid access key")
}
return accessKeyID, nil
}
// InitSignatureV4 initializing signature verification
func InitSignatureV4(req *http.Request) (*donut.Signature, error) {
// strip auth from authorization header
ah := req.Header.Get("Authorization")
accessKeyID, err := StripAccessKeyID(ah)
if err != nil {
return nil, iodine.New(err, nil)
}
authConfig, err := auth.LoadConfig()
if _, ok := authConfig.Users[accessKeyID]; !ok {
return nil, errors.New("Access ID not found")
}
signature := &donut.Signature{
AccessKeyID: authConfig.Users[accessKeyID].AccessKeyID,
SecretAccessKey: authConfig.Users[accessKeyID].SecretAccessKey,
AuthHeader: ah,
Request: req,
}
return signature, nil
}

View File

@ -21,7 +21,6 @@ import (
"io/ioutil" "io/ioutil"
"strings" "strings"
"testing" "testing"
"time"
"encoding/xml" "encoding/xml"
"net/http" "net/http"
@ -49,16 +48,9 @@ func (s *MyAPIDonutCacheSuite) TearDownSuite(c *C) {
testAPIDonutCacheServer.Close() testAPIDonutCacheServer.Close()
} }
func setDummyAuthHeader(req *http.Request) {
authDummy := "AWS4-HMAC-SHA256 Credential=AC5NH40NQLTL4DUMMY/20130524/us-east-1/s3/aws4_request, SignedHeaders=date;host;x-amz-content-sha256;x-amz-date;x-amz-storage-class, Signature=98ad721746da40c64f1a55b78f14c238d841ea1380cd77a1b5971af0ece108bd"
req.Header.Set("Authorization", authDummy)
req.Header.Set("Date", time.Now().UTC().Format(http.TimeFormat))
}
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)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -69,7 +61,6 @@ func (s *MyAPIDonutCacheSuite) TestNonExistantBucket(c *C) {
func (s *MyAPIDonutCacheSuite) TestEmptyObject(c *C) { func (s *MyAPIDonutCacheSuite) TestEmptyObject(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/emptyobject", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/emptyobject", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -78,7 +69,6 @@ func (s *MyAPIDonutCacheSuite) TestEmptyObject(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/emptyobject/object", nil) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/emptyobject/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -87,7 +77,6 @@ func (s *MyAPIDonutCacheSuite) TestEmptyObject(c *C) {
request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/emptyobject/object", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/emptyobject/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -103,7 +92,6 @@ func (s *MyAPIDonutCacheSuite) TestEmptyObject(c *C) {
func (s *MyAPIDonutCacheSuite) TestBucket(c *C) { func (s *MyAPIDonutCacheSuite) TestBucket(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/bucket", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/bucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -112,7 +100,6 @@ func (s *MyAPIDonutCacheSuite) TestBucket(c *C) {
request, err = http.NewRequest("HEAD", testAPIDonutCacheServer.URL+"/bucket", nil) request, err = http.NewRequest("HEAD", testAPIDonutCacheServer.URL+"/bucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -124,7 +111,6 @@ func (s *MyAPIDonutCacheSuite) TestObject(c *C) {
buffer := bytes.NewBufferString("hello world") buffer := bytes.NewBufferString("hello world")
request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/testobject", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/testobject", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -133,7 +119,6 @@ func (s *MyAPIDonutCacheSuite) TestObject(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/testobject/object", buffer) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/testobject/object", buffer)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -142,7 +127,6 @@ func (s *MyAPIDonutCacheSuite) TestObject(c *C) {
request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/testobject/object", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/testobject/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -158,7 +142,6 @@ func (s *MyAPIDonutCacheSuite) TestObject(c *C) {
func (s *MyAPIDonutCacheSuite) TestMultipleObjects(c *C) { func (s *MyAPIDonutCacheSuite) TestMultipleObjects(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/multipleobjects", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/multipleobjects", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -167,7 +150,6 @@ func (s *MyAPIDonutCacheSuite) TestMultipleObjects(c *C) {
request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/multipleobjects/object", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/multipleobjects/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -180,7 +162,6 @@ func (s *MyAPIDonutCacheSuite) TestMultipleObjects(c *C) {
buffer1 := bytes.NewBufferString("hello one") buffer1 := bytes.NewBufferString("hello one")
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/multipleobjects/object1", buffer1) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/multipleobjects/object1", buffer1)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -189,7 +170,6 @@ func (s *MyAPIDonutCacheSuite) TestMultipleObjects(c *C) {
request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/multipleobjects/object1", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/multipleobjects/object1", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -204,7 +184,6 @@ func (s *MyAPIDonutCacheSuite) TestMultipleObjects(c *C) {
buffer2 := bytes.NewBufferString("hello two") buffer2 := bytes.NewBufferString("hello two")
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/multipleobjects/object2", buffer2) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/multipleobjects/object2", buffer2)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -213,7 +192,6 @@ func (s *MyAPIDonutCacheSuite) TestMultipleObjects(c *C) {
request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/multipleobjects/object2", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/multipleobjects/object2", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -228,7 +206,6 @@ func (s *MyAPIDonutCacheSuite) TestMultipleObjects(c *C) {
buffer3 := bytes.NewBufferString("hello three") buffer3 := bytes.NewBufferString("hello three")
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/multipleobjects/object3", buffer3) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/multipleobjects/object3", buffer3)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -237,7 +214,6 @@ func (s *MyAPIDonutCacheSuite) TestMultipleObjects(c *C) {
request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/multipleobjects/object3", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/multipleobjects/object3", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -253,7 +229,6 @@ func (s *MyAPIDonutCacheSuite) TestMultipleObjects(c *C) {
func (s *MyAPIDonutCacheSuite) TestNotImplemented(c *C) { func (s *MyAPIDonutCacheSuite) TestNotImplemented(c *C) {
request, err := http.NewRequest("GET", testAPIDonutCacheServer.URL+"/bucket/object?policy", nil) request, err := http.NewRequest("GET", testAPIDonutCacheServer.URL+"/bucket/object?policy", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -265,7 +240,6 @@ func (s *MyAPIDonutCacheSuite) TestNotImplemented(c *C) {
func (s *MyAPIDonutCacheSuite) TestHeader(c *C) { func (s *MyAPIDonutCacheSuite) TestHeader(c *C) {
request, err := http.NewRequest("GET", testAPIDonutCacheServer.URL+"/bucket/object", nil) request, err := http.NewRequest("GET", testAPIDonutCacheServer.URL+"/bucket/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -278,7 +252,6 @@ func (s *MyAPIDonutCacheSuite) TestPutBucket(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/put-bucket", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/put-bucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private") request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -290,7 +263,6 @@ func (s *MyAPIDonutCacheSuite) TestPutObject(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/put-object", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/put-object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private") request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -299,7 +271,6 @@ func (s *MyAPIDonutCacheSuite) TestPutObject(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/put-object/object", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/put-object/object", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -309,7 +280,6 @@ func (s *MyAPIDonutCacheSuite) TestPutObject(c *C) {
func (s *MyAPIDonutCacheSuite) TestListBuckets(c *C) { func (s *MyAPIDonutCacheSuite) TestListBuckets(c *C) {
request, err := http.NewRequest("GET", testAPIDonutCacheServer.URL+"/", nil) request, err := http.NewRequest("GET", testAPIDonutCacheServer.URL+"/", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -325,7 +295,6 @@ func (s *MyAPIDonutCacheSuite) TestListBuckets(c *C) {
func (s *MyAPIDonutCacheSuite) TestNotBeAbleToCreateObjectInNonexistantBucket(c *C) { func (s *MyAPIDonutCacheSuite) TestNotBeAbleToCreateObjectInNonexistantBucket(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/innonexistantbucket/object", bytes.NewBufferString("hello world")) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/innonexistantbucket/object", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -337,7 +306,6 @@ func (s *MyAPIDonutCacheSuite) TestHeadOnObject(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/headonobject", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/headonobject", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private") request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -346,7 +314,6 @@ func (s *MyAPIDonutCacheSuite) TestHeadOnObject(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/headonobject/object1", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/headonobject/object1", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -354,7 +321,6 @@ func (s *MyAPIDonutCacheSuite) TestHeadOnObject(c *C) {
request, err = http.NewRequest("HEAD", testAPIDonutCacheServer.URL+"/headonobject/object1", nil) request, err = http.NewRequest("HEAD", testAPIDonutCacheServer.URL+"/headonobject/object1", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -365,7 +331,6 @@ func (s *MyAPIDonutCacheSuite) TestHeadOnBucket(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/headonbucket", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/headonbucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private") request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -374,18 +339,17 @@ func (s *MyAPIDonutCacheSuite) TestHeadOnBucket(c *C) {
request, err = http.NewRequest("HEAD", testAPIDonutCacheServer.URL+"/headonbucket", nil) request, err = http.NewRequest("HEAD", testAPIDonutCacheServer.URL+"/headonbucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
} }
/* Enable when we have full working signature v4
func (s *MyAPIDonutCacheSuite) TestDateFormat(c *C) { func (s *MyAPIDonutCacheSuite) TestDateFormat(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/dateformat", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/dateformat", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private") request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
// set an invalid date // set an invalid date
request.Header.Set("Date", "asfasdfadf") request.Header.Set("Date", "asfasdfadf")
@ -397,16 +361,15 @@ func (s *MyAPIDonutCacheSuite) TestDateFormat(c *C) {
"The difference between the request time and the server's time is too large.", http.StatusForbidden) "The difference between the request time and the server's time is too large.", http.StatusForbidden)
request.Header.Set("Date", time.Now().UTC().Format(http.TimeFormat)) request.Header.Set("Date", time.Now().UTC().Format(http.TimeFormat))
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
} }
*/
func (s *MyAPIDonutCacheSuite) TestXMLNameNotInBucketListJson(c *C) { func (s *MyAPIDonutCacheSuite) TestXMLNameNotInBucketListJson(c *C) {
request, err := http.NewRequest("GET", testAPIDonutCacheServer.URL+"/", nil) request, err := http.NewRequest("GET", testAPIDonutCacheServer.URL+"/", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("Accept", "application/json") request.Header.Add("Accept", "application/json")
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -422,7 +385,6 @@ func (s *MyAPIDonutCacheSuite) TestXMLNameNotInObjectListJson(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/xmlnamenotinobjectlistjson", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/xmlnamenotinobjectlistjson", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("Accept", "application/json") request.Header.Add("Accept", "application/json")
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -432,7 +394,6 @@ func (s *MyAPIDonutCacheSuite) TestXMLNameNotInObjectListJson(c *C) {
request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/xmlnamenotinobjectlistjson", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/xmlnamenotinobjectlistjson", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("Accept", "application/json") request.Header.Add("Accept", "application/json")
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -447,7 +408,6 @@ func (s *MyAPIDonutCacheSuite) TestXMLNameNotInObjectListJson(c *C) {
func (s *MyAPIDonutCacheSuite) TestContentTypePersists(c *C) { func (s *MyAPIDonutCacheSuite) TestContentTypePersists(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/contenttype-persists", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/contenttype-persists", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -457,7 +417,6 @@ func (s *MyAPIDonutCacheSuite) TestContentTypePersists(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/contenttype-persists/one", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/contenttype-persists/one", bytes.NewBufferString("hello world"))
delete(request.Header, "Content-Type") delete(request.Header, "Content-Type")
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -466,7 +425,6 @@ func (s *MyAPIDonutCacheSuite) TestContentTypePersists(c *C) {
request, err = http.NewRequest("HEAD", testAPIDonutCacheServer.URL+"/contenttype-persists/one", nil) request, err = http.NewRequest("HEAD", testAPIDonutCacheServer.URL+"/contenttype-persists/one", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -474,7 +432,6 @@ func (s *MyAPIDonutCacheSuite) TestContentTypePersists(c *C) {
request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/contenttype-persists/one", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/contenttype-persists/one", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -486,7 +443,6 @@ func (s *MyAPIDonutCacheSuite) TestContentTypePersists(c *C) {
delete(request.Header, "Content-Type") delete(request.Header, "Content-Type")
request.Header.Add("Content-Type", "application/json") request.Header.Add("Content-Type", "application/json")
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -494,7 +450,6 @@ func (s *MyAPIDonutCacheSuite) TestContentTypePersists(c *C) {
request, err = http.NewRequest("HEAD", testAPIDonutCacheServer.URL+"/contenttype-persists/two", nil) request, err = http.NewRequest("HEAD", testAPIDonutCacheServer.URL+"/contenttype-persists/two", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -502,7 +457,6 @@ func (s *MyAPIDonutCacheSuite) TestContentTypePersists(c *C) {
request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/contenttype-persists/two", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/contenttype-persists/two", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -512,7 +466,6 @@ func (s *MyAPIDonutCacheSuite) TestContentTypePersists(c *C) {
func (s *MyAPIDonutCacheSuite) TestPartialContent(c *C) { func (s *MyAPIDonutCacheSuite) TestPartialContent(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/partial-content", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/partial-content", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -521,7 +474,6 @@ func (s *MyAPIDonutCacheSuite) TestPartialContent(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/partial-content/bar", bytes.NewBufferString("Hello World")) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/partial-content/bar", bytes.NewBufferString("Hello World"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -533,7 +485,6 @@ func (s *MyAPIDonutCacheSuite) TestPartialContent(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("Accept", "application/json") request.Header.Add("Accept", "application/json")
request.Header.Add("Range", "bytes=6-7") request.Header.Add("Range", "bytes=6-7")
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -548,7 +499,6 @@ func (s *MyAPIDonutCacheSuite) TestPartialContent(c *C) {
func (s *MyAPIDonutCacheSuite) TestListObjectsHandlerErrors(c *C) { func (s *MyAPIDonutCacheSuite) TestListObjectsHandlerErrors(c *C) {
request, err := http.NewRequest("GET", testAPIDonutCacheServer.URL+"/objecthandlererrors-.", nil) request, err := http.NewRequest("GET", testAPIDonutCacheServer.URL+"/objecthandlererrors-.", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -557,7 +507,6 @@ func (s *MyAPIDonutCacheSuite) TestListObjectsHandlerErrors(c *C) {
request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/objecthandlererrors", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/objecthandlererrors", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -569,7 +518,6 @@ func (s *MyAPIDonutCacheSuite) TestPutBucketErrors(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/putbucket-.", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/putbucket-.", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private") request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -579,7 +527,6 @@ func (s *MyAPIDonutCacheSuite) TestPutBucketErrors(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/putbucket", nil) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/putbucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private") request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -589,7 +536,6 @@ func (s *MyAPIDonutCacheSuite) TestPutBucketErrors(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/putbucket", nil) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/putbucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private") request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -598,7 +544,6 @@ func (s *MyAPIDonutCacheSuite) TestPutBucketErrors(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/putbucket?acl", nil) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/putbucket?acl", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "unknown") request.Header.Add("x-amz-acl", "unknown")
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -608,7 +553,6 @@ func (s *MyAPIDonutCacheSuite) TestPutBucketErrors(c *C) {
func (s *MyAPIDonutCacheSuite) TestGetObjectErrors(c *C) { func (s *MyAPIDonutCacheSuite) TestGetObjectErrors(c *C) {
request, err := http.NewRequest("GET", testAPIDonutCacheServer.URL+"/getobjecterrors", nil) request, err := http.NewRequest("GET", testAPIDonutCacheServer.URL+"/getobjecterrors", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -617,7 +561,6 @@ func (s *MyAPIDonutCacheSuite) TestGetObjectErrors(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/getobjecterrors", nil) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/getobjecterrors", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -626,7 +569,6 @@ func (s *MyAPIDonutCacheSuite) TestGetObjectErrors(c *C) {
request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/getobjecterrors/bar", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/getobjecterrors/bar", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -635,7 +577,6 @@ func (s *MyAPIDonutCacheSuite) TestGetObjectErrors(c *C) {
request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/getobjecterrors-./bar", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/getobjecterrors-./bar", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -646,7 +587,6 @@ func (s *MyAPIDonutCacheSuite) TestGetObjectErrors(c *C) {
func (s *MyAPIDonutCacheSuite) TestGetObjectRangeErrors(c *C) { func (s *MyAPIDonutCacheSuite) TestGetObjectRangeErrors(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/getobjectrangeerrors", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/getobjectrangeerrors", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -655,7 +595,6 @@ func (s *MyAPIDonutCacheSuite) TestGetObjectRangeErrors(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/getobjectrangeerrors/bar", bytes.NewBufferString("Hello World")) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/getobjectrangeerrors/bar", bytes.NewBufferString("Hello World"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -665,7 +604,6 @@ func (s *MyAPIDonutCacheSuite) TestGetObjectRangeErrors(c *C) {
request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/getobjectrangeerrors/bar", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/getobjectrangeerrors/bar", nil)
request.Header.Add("Range", "bytes=7-6") request.Header.Add("Range", "bytes=7-6")
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -676,7 +614,6 @@ func (s *MyAPIDonutCacheSuite) TestGetObjectRangeErrors(c *C) {
func (s *MyAPIDonutCacheSuite) TestObjectMultipartAbort(c *C) { func (s *MyAPIDonutCacheSuite) TestObjectMultipartAbort(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultipartabort", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultipartabort", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -685,7 +622,6 @@ func (s *MyAPIDonutCacheSuite) TestObjectMultipartAbort(c *C) {
request, err = http.NewRequest("POST", testAPIDonutCacheServer.URL+"/objectmultipartabort/object?uploads", bytes.NewBufferString("")) request, err = http.NewRequest("POST", testAPIDonutCacheServer.URL+"/objectmultipartabort/object?uploads", bytes.NewBufferString(""))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
@ -700,7 +636,6 @@ func (s *MyAPIDonutCacheSuite) TestObjectMultipartAbort(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultipartabort/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultipartabort/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response1, err := client.Do(request) response1, err := client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -708,7 +643,6 @@ func (s *MyAPIDonutCacheSuite) TestObjectMultipartAbort(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultipartabort/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultipartabort/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response2, err := client.Do(request) response2, err := client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -716,7 +650,6 @@ func (s *MyAPIDonutCacheSuite) TestObjectMultipartAbort(c *C) {
request, err = http.NewRequest("DELETE", testAPIDonutCacheServer.URL+"/objectmultipartabort/object?uploadId="+uploadID, nil) request, err = http.NewRequest("DELETE", testAPIDonutCacheServer.URL+"/objectmultipartabort/object?uploadId="+uploadID, nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response3, err := client.Do(request) response3, err := client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -726,7 +659,6 @@ func (s *MyAPIDonutCacheSuite) TestObjectMultipartAbort(c *C) {
func (s *MyAPIDonutCacheSuite) TestBucketMultipartList(c *C) { func (s *MyAPIDonutCacheSuite) TestBucketMultipartList(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/bucketmultipartlist", bytes.NewBufferString("")) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/bucketmultipartlist", bytes.NewBufferString(""))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -735,7 +667,6 @@ func (s *MyAPIDonutCacheSuite) TestBucketMultipartList(c *C) {
request, err = http.NewRequest("POST", testAPIDonutCacheServer.URL+"/bucketmultipartlist/object?uploads", bytes.NewBufferString("")) request, err = http.NewRequest("POST", testAPIDonutCacheServer.URL+"/bucketmultipartlist/object?uploads", bytes.NewBufferString(""))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
@ -750,7 +681,6 @@ func (s *MyAPIDonutCacheSuite) TestBucketMultipartList(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/bucketmultipartlist/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/bucketmultipartlist/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response1, err := client.Do(request) response1, err := client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -758,7 +688,6 @@ func (s *MyAPIDonutCacheSuite) TestBucketMultipartList(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/bucketmultipartlist/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/bucketmultipartlist/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response2, err := client.Do(request) response2, err := client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -766,7 +695,6 @@ func (s *MyAPIDonutCacheSuite) TestBucketMultipartList(c *C) {
request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/bucketmultipartlist?uploads", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/bucketmultipartlist?uploads", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response3, err := client.Do(request) response3, err := client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -782,7 +710,6 @@ func (s *MyAPIDonutCacheSuite) TestBucketMultipartList(c *C) {
func (s *MyAPIDonutCacheSuite) TestObjectMultipartList(c *C) { func (s *MyAPIDonutCacheSuite) TestObjectMultipartList(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultipartlist", bytes.NewBufferString("")) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultipartlist", bytes.NewBufferString(""))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -791,7 +718,6 @@ func (s *MyAPIDonutCacheSuite) TestObjectMultipartList(c *C) {
request, err = http.NewRequest("POST", testAPIDonutCacheServer.URL+"/objectmultipartlist/object?uploads", bytes.NewBufferString("")) request, err = http.NewRequest("POST", testAPIDonutCacheServer.URL+"/objectmultipartlist/object?uploads", bytes.NewBufferString(""))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
@ -806,7 +732,6 @@ func (s *MyAPIDonutCacheSuite) TestObjectMultipartList(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultipartlist/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultipartlist/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response1, err := client.Do(request) response1, err := client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -814,7 +739,6 @@ func (s *MyAPIDonutCacheSuite) TestObjectMultipartList(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultipartlist/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultipartlist/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response2, err := client.Do(request) response2, err := client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -822,7 +746,6 @@ func (s *MyAPIDonutCacheSuite) TestObjectMultipartList(c *C) {
request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/objectmultipartlist/object?uploadId="+uploadID, nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/objectmultipartlist/object?uploadId="+uploadID, nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response3, err := client.Do(request) response3, err := client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -833,7 +756,6 @@ func (s *MyAPIDonutCacheSuite) TestObjectMultipartList(c *C) {
func (s *MyAPIDonutCacheSuite) TestObjectMultipart(c *C) { func (s *MyAPIDonutCacheSuite) TestObjectMultipart(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultiparts", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultiparts", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -842,7 +764,6 @@ func (s *MyAPIDonutCacheSuite) TestObjectMultipart(c *C) {
request, err = http.NewRequest("POST", testAPIDonutCacheServer.URL+"/objectmultiparts/object?uploads", nil) request, err = http.NewRequest("POST", testAPIDonutCacheServer.URL+"/objectmultiparts/object?uploads", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -859,7 +780,6 @@ func (s *MyAPIDonutCacheSuite) TestObjectMultipart(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultiparts/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultiparts/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response1, err := client.Do(request) response1, err := client.Do(request)
@ -868,7 +788,6 @@ func (s *MyAPIDonutCacheSuite) TestObjectMultipart(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultiparts/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultiparts/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response2, err := client.Do(request) response2, err := client.Do(request)
@ -895,7 +814,6 @@ func (s *MyAPIDonutCacheSuite) TestObjectMultipart(c *C) {
request, err = http.NewRequest("POST", testAPIDonutCacheServer.URL+"/objectmultiparts/object?uploadId="+uploadID, &completeBuffer) request, err = http.NewRequest("POST", testAPIDonutCacheServer.URL+"/objectmultiparts/object?uploadId="+uploadID, &completeBuffer)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -903,7 +821,6 @@ func (s *MyAPIDonutCacheSuite) TestObjectMultipart(c *C) {
request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/objectmultiparts/object", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/objectmultiparts/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)

View File

@ -24,7 +24,6 @@ import (
"strconv" "strconv"
"strings" "strings"
"testing" "testing"
"time"
"encoding/xml" "encoding/xml"
"net/http" "net/http"
@ -88,7 +87,6 @@ func (s *MyAPIDonutSuite) TearDownSuite(c *C) {
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)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -99,7 +97,6 @@ func (s *MyAPIDonutSuite) TestNonExistantBucket(c *C) {
func (s *MyAPIDonutSuite) TestEmptyObject(c *C) { func (s *MyAPIDonutSuite) TestEmptyObject(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/emptyobject", nil) request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/emptyobject", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -108,7 +105,6 @@ func (s *MyAPIDonutSuite) TestEmptyObject(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/emptyobject/object", nil) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/emptyobject/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -117,7 +113,6 @@ func (s *MyAPIDonutSuite) TestEmptyObject(c *C) {
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/emptyobject/object", nil) request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/emptyobject/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -133,7 +128,6 @@ func (s *MyAPIDonutSuite) TestEmptyObject(c *C) {
func (s *MyAPIDonutSuite) TestBucket(c *C) { func (s *MyAPIDonutSuite) TestBucket(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/bucket", nil) request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/bucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -142,7 +136,6 @@ func (s *MyAPIDonutSuite) TestBucket(c *C) {
request, err = http.NewRequest("HEAD", testAPIDonutServer.URL+"/bucket", nil) request, err = http.NewRequest("HEAD", testAPIDonutServer.URL+"/bucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -154,7 +147,6 @@ func (s *MyAPIDonutSuite) TestObject(c *C) {
buffer := bytes.NewBufferString("hello world") buffer := bytes.NewBufferString("hello world")
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/testobject", nil) request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/testobject", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -163,7 +155,6 @@ func (s *MyAPIDonutSuite) TestObject(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/testobject/object", buffer) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/testobject/object", buffer)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -172,7 +163,6 @@ func (s *MyAPIDonutSuite) TestObject(c *C) {
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/testobject/object", nil) request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/testobject/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -188,7 +178,6 @@ func (s *MyAPIDonutSuite) TestObject(c *C) {
func (s *MyAPIDonutSuite) TestMultipleObjects(c *C) { func (s *MyAPIDonutSuite) TestMultipleObjects(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/multipleobjects", nil) request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/multipleobjects", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -197,7 +186,6 @@ func (s *MyAPIDonutSuite) TestMultipleObjects(c *C) {
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/multipleobjects/object", nil) request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/multipleobjects/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -210,7 +198,6 @@ func (s *MyAPIDonutSuite) TestMultipleObjects(c *C) {
buffer1 := bytes.NewBufferString("hello one") buffer1 := bytes.NewBufferString("hello one")
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/multipleobjects/object1", buffer1) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/multipleobjects/object1", buffer1)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -219,7 +206,6 @@ func (s *MyAPIDonutSuite) TestMultipleObjects(c *C) {
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/multipleobjects/object1", nil) request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/multipleobjects/object1", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -234,7 +220,6 @@ func (s *MyAPIDonutSuite) TestMultipleObjects(c *C) {
buffer2 := bytes.NewBufferString("hello two") buffer2 := bytes.NewBufferString("hello two")
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/multipleobjects/object2", buffer2) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/multipleobjects/object2", buffer2)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -243,7 +228,6 @@ func (s *MyAPIDonutSuite) TestMultipleObjects(c *C) {
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/multipleobjects/object2", nil) request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/multipleobjects/object2", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -258,7 +242,6 @@ func (s *MyAPIDonutSuite) TestMultipleObjects(c *C) {
buffer3 := bytes.NewBufferString("hello three") buffer3 := bytes.NewBufferString("hello three")
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/multipleobjects/object3", buffer3) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/multipleobjects/object3", buffer3)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -267,7 +250,6 @@ func (s *MyAPIDonutSuite) TestMultipleObjects(c *C) {
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/multipleobjects/object3", nil) request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/multipleobjects/object3", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -283,7 +265,6 @@ func (s *MyAPIDonutSuite) TestMultipleObjects(c *C) {
func (s *MyAPIDonutSuite) TestNotImplemented(c *C) { func (s *MyAPIDonutSuite) TestNotImplemented(c *C) {
request, err := http.NewRequest("GET", testAPIDonutServer.URL+"/bucket/object?policy", nil) request, err := http.NewRequest("GET", testAPIDonutServer.URL+"/bucket/object?policy", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -295,7 +276,6 @@ func (s *MyAPIDonutSuite) TestNotImplemented(c *C) {
func (s *MyAPIDonutSuite) TestHeader(c *C) { func (s *MyAPIDonutSuite) TestHeader(c *C) {
request, err := http.NewRequest("GET", testAPIDonutServer.URL+"/bucket/object", nil) request, err := http.NewRequest("GET", testAPIDonutServer.URL+"/bucket/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -308,7 +288,6 @@ func (s *MyAPIDonutSuite) TestPutBucket(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/put-bucket", nil) request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/put-bucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private") request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -320,7 +299,6 @@ func (s *MyAPIDonutSuite) TestPutObject(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/put-object", nil) request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/put-object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private") request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -329,7 +307,6 @@ func (s *MyAPIDonutSuite) TestPutObject(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/put-object/object", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/put-object/object", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -339,7 +316,6 @@ func (s *MyAPIDonutSuite) TestPutObject(c *C) {
func (s *MyAPIDonutSuite) TestListBuckets(c *C) { func (s *MyAPIDonutSuite) TestListBuckets(c *C) {
request, err := http.NewRequest("GET", testAPIDonutServer.URL+"/", nil) request, err := http.NewRequest("GET", testAPIDonutServer.URL+"/", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -355,7 +331,6 @@ func (s *MyAPIDonutSuite) TestListBuckets(c *C) {
func (s *MyAPIDonutSuite) TestNotBeAbleToCreateObjectInNonexistantBucket(c *C) { func (s *MyAPIDonutSuite) TestNotBeAbleToCreateObjectInNonexistantBucket(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/innonexistantbucket/object", bytes.NewBufferString("hello world")) request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/innonexistantbucket/object", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -367,7 +342,6 @@ func (s *MyAPIDonutSuite) TestHeadOnObject(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/headonobject", nil) request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/headonobject", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private") request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -376,7 +350,6 @@ func (s *MyAPIDonutSuite) TestHeadOnObject(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/headonobject/object1", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/headonobject/object1", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -384,7 +357,6 @@ func (s *MyAPIDonutSuite) TestHeadOnObject(c *C) {
request, err = http.NewRequest("HEAD", testAPIDonutServer.URL+"/headonobject/object1", nil) request, err = http.NewRequest("HEAD", testAPIDonutServer.URL+"/headonobject/object1", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -395,7 +367,6 @@ func (s *MyAPIDonutSuite) TestHeadOnBucket(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/headonbucket", nil) request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/headonbucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private") request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -404,18 +375,17 @@ func (s *MyAPIDonutSuite) TestHeadOnBucket(c *C) {
request, err = http.NewRequest("HEAD", testAPIDonutServer.URL+"/headonbucket", nil) request, err = http.NewRequest("HEAD", testAPIDonutServer.URL+"/headonbucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
} }
/*
func (s *MyAPIDonutSuite) TestDateFormat(c *C) { func (s *MyAPIDonutSuite) TestDateFormat(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/dateformat", nil) request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/dateformat", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private") request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
// set an invalid date // set an invalid date
request.Header.Set("Date", "asfasdfadf") request.Header.Set("Date", "asfasdfadf")
@ -427,16 +397,16 @@ func (s *MyAPIDonutSuite) TestDateFormat(c *C) {
"The difference between the request time and the server's time is too large.", http.StatusForbidden) "The difference between the request time and the server's time is too large.", http.StatusForbidden)
request.Header.Set("Date", time.Now().UTC().Format(http.TimeFormat)) request.Header.Set("Date", time.Now().UTC().Format(http.TimeFormat))
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
} }
*/
func (s *MyAPIDonutSuite) TestXMLNameNotInBucketListJson(c *C) { func (s *MyAPIDonutSuite) TestXMLNameNotInBucketListJson(c *C) {
request, err := http.NewRequest("GET", testAPIDonutServer.URL+"/", nil) request, err := http.NewRequest("GET", testAPIDonutServer.URL+"/", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("Accept", "application/json") request.Header.Add("Accept", "application/json")
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -452,7 +422,6 @@ func (s *MyAPIDonutSuite) TestXMLNameNotInObjectListJson(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/xmlnamenotinobjectlistjson", nil) request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/xmlnamenotinobjectlistjson", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("Accept", "application/json") request.Header.Add("Accept", "application/json")
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -462,7 +431,6 @@ func (s *MyAPIDonutSuite) TestXMLNameNotInObjectListJson(c *C) {
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/xmlnamenotinobjectlistjson", nil) request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/xmlnamenotinobjectlistjson", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("Accept", "application/json") request.Header.Add("Accept", "application/json")
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -477,7 +445,6 @@ func (s *MyAPIDonutSuite) TestXMLNameNotInObjectListJson(c *C) {
func (s *MyAPIDonutSuite) TestContentTypePersists(c *C) { func (s *MyAPIDonutSuite) TestContentTypePersists(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/contenttype-persists", nil) request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/contenttype-persists", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -487,7 +454,6 @@ func (s *MyAPIDonutSuite) TestContentTypePersists(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/contenttype-persists/one", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/contenttype-persists/one", bytes.NewBufferString("hello world"))
delete(request.Header, "Content-Type") delete(request.Header, "Content-Type")
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -496,7 +462,6 @@ func (s *MyAPIDonutSuite) TestContentTypePersists(c *C) {
request, err = http.NewRequest("HEAD", testAPIDonutServer.URL+"/contenttype-persists/one", nil) request, err = http.NewRequest("HEAD", testAPIDonutServer.URL+"/contenttype-persists/one", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -504,7 +469,6 @@ func (s *MyAPIDonutSuite) TestContentTypePersists(c *C) {
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/contenttype-persists/one", nil) request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/contenttype-persists/one", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -516,7 +480,6 @@ func (s *MyAPIDonutSuite) TestContentTypePersists(c *C) {
delete(request.Header, "Content-Type") delete(request.Header, "Content-Type")
request.Header.Add("Content-Type", "application/json") request.Header.Add("Content-Type", "application/json")
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -524,7 +487,6 @@ func (s *MyAPIDonutSuite) TestContentTypePersists(c *C) {
request, err = http.NewRequest("HEAD", testAPIDonutServer.URL+"/contenttype-persists/two", nil) request, err = http.NewRequest("HEAD", testAPIDonutServer.URL+"/contenttype-persists/two", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -532,7 +494,6 @@ func (s *MyAPIDonutSuite) TestContentTypePersists(c *C) {
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/contenttype-persists/two", nil) request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/contenttype-persists/two", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -542,7 +503,6 @@ func (s *MyAPIDonutSuite) TestContentTypePersists(c *C) {
func (s *MyAPIDonutSuite) TestPartialContent(c *C) { func (s *MyAPIDonutSuite) TestPartialContent(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/partial-content", nil) request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/partial-content", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -551,7 +511,6 @@ func (s *MyAPIDonutSuite) TestPartialContent(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/partial-content/bar", bytes.NewBufferString("Hello World")) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/partial-content/bar", bytes.NewBufferString("Hello World"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -563,7 +522,6 @@ func (s *MyAPIDonutSuite) TestPartialContent(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("Accept", "application/json") request.Header.Add("Accept", "application/json")
request.Header.Add("Range", "bytes=6-7") request.Header.Add("Range", "bytes=6-7")
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -578,7 +536,6 @@ func (s *MyAPIDonutSuite) TestPartialContent(c *C) {
func (s *MyAPIDonutSuite) TestListObjectsHandlerErrors(c *C) { func (s *MyAPIDonutSuite) TestListObjectsHandlerErrors(c *C) {
request, err := http.NewRequest("GET", testAPIDonutServer.URL+"/objecthandlererrors-.", nil) request, err := http.NewRequest("GET", testAPIDonutServer.URL+"/objecthandlererrors-.", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -587,7 +544,6 @@ func (s *MyAPIDonutSuite) TestListObjectsHandlerErrors(c *C) {
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/objecthandlererrors", nil) request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/objecthandlererrors", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -599,7 +555,6 @@ func (s *MyAPIDonutSuite) TestPutBucketErrors(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/putbucket-.", nil) request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/putbucket-.", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private") request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -609,7 +564,6 @@ func (s *MyAPIDonutSuite) TestPutBucketErrors(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/putbucket", nil) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/putbucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private") request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -619,7 +573,6 @@ func (s *MyAPIDonutSuite) TestPutBucketErrors(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/putbucket", nil) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/putbucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private") request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -628,7 +581,6 @@ func (s *MyAPIDonutSuite) TestPutBucketErrors(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/putbucket?acl", nil) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/putbucket?acl", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "unknown") request.Header.Add("x-amz-acl", "unknown")
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -638,7 +590,6 @@ func (s *MyAPIDonutSuite) TestPutBucketErrors(c *C) {
func (s *MyAPIDonutSuite) TestGetObjectErrors(c *C) { func (s *MyAPIDonutSuite) TestGetObjectErrors(c *C) {
request, err := http.NewRequest("GET", testAPIDonutServer.URL+"/getobjecterrors", nil) request, err := http.NewRequest("GET", testAPIDonutServer.URL+"/getobjecterrors", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -647,7 +598,6 @@ func (s *MyAPIDonutSuite) TestGetObjectErrors(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/getobjecterrors", nil) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/getobjecterrors", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -656,7 +606,6 @@ func (s *MyAPIDonutSuite) TestGetObjectErrors(c *C) {
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/getobjecterrors/bar", nil) request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/getobjecterrors/bar", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -665,7 +614,6 @@ func (s *MyAPIDonutSuite) TestGetObjectErrors(c *C) {
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/getobjecterrors-./bar", nil) request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/getobjecterrors-./bar", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -676,7 +624,6 @@ func (s *MyAPIDonutSuite) TestGetObjectErrors(c *C) {
func (s *MyAPIDonutSuite) TestGetObjectRangeErrors(c *C) { func (s *MyAPIDonutSuite) TestGetObjectRangeErrors(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/getobjectrangeerrors", nil) request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/getobjectrangeerrors", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -685,7 +632,6 @@ func (s *MyAPIDonutSuite) TestGetObjectRangeErrors(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/getobjectrangeerrors/bar", bytes.NewBufferString("Hello World")) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/getobjectrangeerrors/bar", bytes.NewBufferString("Hello World"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -695,7 +641,6 @@ func (s *MyAPIDonutSuite) TestGetObjectRangeErrors(c *C) {
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/getobjectrangeerrors/bar", nil) request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/getobjectrangeerrors/bar", nil)
request.Header.Add("Range", "bytes=7-6") request.Header.Add("Range", "bytes=7-6")
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -706,7 +651,6 @@ func (s *MyAPIDonutSuite) TestGetObjectRangeErrors(c *C) {
func (s *MyAPIDonutSuite) TestObjectMultipartAbort(c *C) { func (s *MyAPIDonutSuite) TestObjectMultipartAbort(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultipartabort", nil) request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultipartabort", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -715,7 +659,6 @@ func (s *MyAPIDonutSuite) TestObjectMultipartAbort(c *C) {
request, err = http.NewRequest("POST", testAPIDonutServer.URL+"/objectmultipartabort/object?uploads", bytes.NewBufferString("")) request, err = http.NewRequest("POST", testAPIDonutServer.URL+"/objectmultipartabort/object?uploads", bytes.NewBufferString(""))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
@ -730,7 +673,6 @@ func (s *MyAPIDonutSuite) TestObjectMultipartAbort(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultipartabort/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultipartabort/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response1, err := client.Do(request) response1, err := client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -738,7 +680,6 @@ func (s *MyAPIDonutSuite) TestObjectMultipartAbort(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultipartabort/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultipartabort/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response2, err := client.Do(request) response2, err := client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -746,7 +687,6 @@ func (s *MyAPIDonutSuite) TestObjectMultipartAbort(c *C) {
request, err = http.NewRequest("DELETE", testAPIDonutServer.URL+"/objectmultipartabort/object?uploadId="+uploadID, nil) request, err = http.NewRequest("DELETE", testAPIDonutServer.URL+"/objectmultipartabort/object?uploadId="+uploadID, nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response3, err := client.Do(request) response3, err := client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -756,7 +696,6 @@ func (s *MyAPIDonutSuite) TestObjectMultipartAbort(c *C) {
func (s *MyAPIDonutSuite) TestBucketMultipartList(c *C) { func (s *MyAPIDonutSuite) TestBucketMultipartList(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/bucketmultipartlist", bytes.NewBufferString("")) request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/bucketmultipartlist", bytes.NewBufferString(""))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -765,7 +704,6 @@ func (s *MyAPIDonutSuite) TestBucketMultipartList(c *C) {
request, err = http.NewRequest("POST", testAPIDonutServer.URL+"/bucketmultipartlist/object?uploads", bytes.NewBufferString("")) request, err = http.NewRequest("POST", testAPIDonutServer.URL+"/bucketmultipartlist/object?uploads", bytes.NewBufferString(""))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
@ -780,7 +718,6 @@ func (s *MyAPIDonutSuite) TestBucketMultipartList(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/bucketmultipartlist/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/bucketmultipartlist/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response1, err := client.Do(request) response1, err := client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -788,7 +725,6 @@ func (s *MyAPIDonutSuite) TestBucketMultipartList(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/bucketmultipartlist/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/bucketmultipartlist/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response2, err := client.Do(request) response2, err := client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -796,7 +732,6 @@ func (s *MyAPIDonutSuite) TestBucketMultipartList(c *C) {
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/bucketmultipartlist?uploads", nil) request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/bucketmultipartlist?uploads", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response3, err := client.Do(request) response3, err := client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -812,7 +747,6 @@ func (s *MyAPIDonutSuite) TestBucketMultipartList(c *C) {
func (s *MyAPIDonutSuite) TestObjectMultipartList(c *C) { func (s *MyAPIDonutSuite) TestObjectMultipartList(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultipartlist", bytes.NewBufferString("")) request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultipartlist", bytes.NewBufferString(""))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -821,7 +755,6 @@ func (s *MyAPIDonutSuite) TestObjectMultipartList(c *C) {
request, err = http.NewRequest("POST", testAPIDonutServer.URL+"/objectmultipartlist/object?uploads", bytes.NewBufferString("")) request, err = http.NewRequest("POST", testAPIDonutServer.URL+"/objectmultipartlist/object?uploads", bytes.NewBufferString(""))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
@ -836,7 +769,6 @@ func (s *MyAPIDonutSuite) TestObjectMultipartList(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultipartlist/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultipartlist/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response1, err := client.Do(request) response1, err := client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -844,7 +776,6 @@ func (s *MyAPIDonutSuite) TestObjectMultipartList(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultipartlist/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultipartlist/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response2, err := client.Do(request) response2, err := client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -852,7 +783,6 @@ func (s *MyAPIDonutSuite) TestObjectMultipartList(c *C) {
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/objectmultipartlist/object?uploadId="+uploadID, nil) request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/objectmultipartlist/object?uploadId="+uploadID, nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response3, err := client.Do(request) response3, err := client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -863,7 +793,6 @@ func (s *MyAPIDonutSuite) TestObjectMultipartList(c *C) {
func (s *MyAPIDonutSuite) TestObjectMultipart(c *C) { func (s *MyAPIDonutSuite) TestObjectMultipart(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultiparts", nil) request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultiparts", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{} client := http.Client{}
response, err := client.Do(request) response, err := client.Do(request)
@ -872,7 +801,6 @@ func (s *MyAPIDonutSuite) TestObjectMultipart(c *C) {
request, err = http.NewRequest("POST", testAPIDonutServer.URL+"/objectmultiparts/object?uploads", nil) request, err = http.NewRequest("POST", testAPIDonutServer.URL+"/objectmultiparts/object?uploads", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response, err = client.Do(request) response, err = client.Do(request)
@ -889,7 +817,6 @@ func (s *MyAPIDonutSuite) TestObjectMultipart(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultiparts/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultiparts/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response1, err := client.Do(request) response1, err := client.Do(request)
@ -898,7 +825,6 @@ func (s *MyAPIDonutSuite) TestObjectMultipart(c *C) {
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultiparts/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultiparts/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{} client = http.Client{}
response2, err := client.Do(request) response2, err := client.Do(request)
@ -925,7 +851,6 @@ func (s *MyAPIDonutSuite) TestObjectMultipart(c *C) {
request, err = http.NewRequest("POST", testAPIDonutServer.URL+"/objectmultiparts/object?uploadId="+uploadID, &completeBuffer) request, err = http.NewRequest("POST", testAPIDonutServer.URL+"/objectmultiparts/object?uploadId="+uploadID, &completeBuffer)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@ -933,7 +858,6 @@ func (s *MyAPIDonutSuite) TestObjectMultipart(c *C) {
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/objectmultiparts/object", nil) request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/objectmultiparts/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request) response, err = client.Do(request)
c.Assert(err, IsNil) c.Assert(err, IsNil)