Merge pull request #718 from harshavardhana/pr_out_add_api_tests_for_both_donut_on_disk_and_donut_cache

Add API tests for both donut on disk and donut cache
This commit is contained in:
Harshavardhana 2015-07-08 02:41:44 +00:00
commit f737c0540e
7 changed files with 1068 additions and 147 deletions

View File

@ -155,13 +155,12 @@ func (b bucket) ListObjects(prefix, marker, delimiter string, maxkeys int) (List
} }
var prefixes []string var prefixes []string
var filteredObjects []string var filteredObjects []string
filteredObjects = objects
if strings.TrimSpace(delimiter) != "" { if strings.TrimSpace(delimiter) != "" {
filteredObjects = HasNoDelimiter(objects, delimiter) filteredObjects = HasNoDelimiter(objects, delimiter)
prefixes = HasDelimiter(objects, delimiter) prefixes = HasDelimiter(objects, delimiter)
prefixes = SplitDelimiter(prefixes, delimiter) prefixes = SplitDelimiter(prefixes, delimiter)
prefixes = SortU(prefixes) prefixes = SortU(prefixes)
} else {
filteredObjects = objects
} }
var results []string var results []string
var commonPrefixes []string var commonPrefixes []string

View File

@ -34,15 +34,15 @@ func getDonutConfigPath() (string, error) {
return donutConfigPath, nil return donutConfigPath, nil
} }
// NOTE - this is not to be used outside Donut package, this is primarily intended for testing purposes only // NOTE - this is not thread safe use it carefully, currently its purpose is only for testing purposes.
var customConfigPath string var CustomConfigPath string
// SaveConfig save donut config // SaveConfig save donut config
func SaveConfig(a *Config) error { func SaveConfig(a *Config) error {
var donutConfigPath string var donutConfigPath string
var err error var err error
if customConfigPath != "" { if CustomConfigPath != "" {
donutConfigPath = customConfigPath donutConfigPath = CustomConfigPath
} else { } else {
donutConfigPath, err = getDonutConfigPath() donutConfigPath, err = getDonutConfigPath()
if err != nil { if err != nil {
@ -63,8 +63,8 @@ func SaveConfig(a *Config) error {
func LoadConfig() (*Config, error) { func LoadConfig() (*Config, error) {
var donutConfigPath string var donutConfigPath string
var err error var err error
if customConfigPath != "" { if CustomConfigPath != "" {
donutConfigPath = customConfigPath donutConfigPath = CustomConfigPath
} else { } else {
donutConfigPath, err = getDonutConfigPath() donutConfigPath, err = getDonutConfigPath()
if err != nil { if err != nil {

View File

@ -66,7 +66,7 @@ func (s *MyDonutSuite) SetUpSuite(c *C) {
conf.DonutName = "test" conf.DonutName = "test"
conf.NodeDiskMap = createTestNodeDiskMap(root) conf.NodeDiskMap = createTestNodeDiskMap(root)
conf.MaxSize = 100000 conf.MaxSize = 100000
customConfigPath = filepath.Join(root, "donut.json") CustomConfigPath = filepath.Join(root, "donut.json")
err = SaveConfig(conf) err = SaveConfig(conf)
c.Assert(err, IsNil) c.Assert(err, IsNil)

View File

@ -500,13 +500,12 @@ func (donut API) ListObjects(bucket string, resources BucketResourcesMetadata) (
} }
var prefixes []string var prefixes []string
var filteredKeys []string var filteredKeys []string
filteredKeys = keys
if strings.TrimSpace(resources.Delimiter) != "" { if strings.TrimSpace(resources.Delimiter) != "" {
filteredKeys = HasNoDelimiter(keys, resources.Delimiter) filteredKeys = HasNoDelimiter(keys, resources.Delimiter)
prefixes = HasDelimiter(keys, resources.Delimiter) prefixes = HasDelimiter(keys, resources.Delimiter)
prefixes = SplitDelimiter(prefixes, resources.Delimiter) prefixes = SplitDelimiter(prefixes, resources.Delimiter)
prefixes = SortU(prefixes) prefixes = SortU(prefixes)
} else {
filteredKeys = keys
} }
for _, commonPrefix := range prefixes { for _, commonPrefix := range prefixes {
resources.CommonPrefixes = append(resources.CommonPrefixes, resources.Prefix+commonPrefix) resources.CommonPrefixes = append(resources.CommonPrefixes, resources.Prefix+commonPrefix)

View File

@ -44,7 +44,7 @@ func (s *MyCacheSuite) SetUpSuite(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
s.root = root s.root = root
customConfigPath = filepath.Join(root, "donut.json") CustomConfigPath = filepath.Join(root, "donut.json")
dc, err = New() dc, err = New()
c.Assert(err, IsNil) c.Assert(err, IsNil)

View File

@ -18,9 +18,7 @@ package server
import ( import (
"bytes" "bytes"
"io"
"io/ioutil" "io/ioutil"
"strconv"
"strings" "strings"
"testing" "testing"
"time" "time"
@ -33,22 +31,22 @@ import (
"github.com/minio/minio/pkg/server/api" "github.com/minio/minio/pkg/server/api"
) )
func TestAPI(t *testing.T) { TestingT(t) } func TestAPIDonutCache(t *testing.T) { TestingT(t) }
type MyAPISuite struct{} type MyAPIDonutCacheSuite struct{}
var _ = Suite(&MyAPISuite{}) var _ = Suite(&MyAPIDonutCacheSuite{})
var testAPIServer *httptest.Server var testAPIDonutCacheServer *httptest.Server
func (s *MyAPISuite) SetUpSuite(c *C) { func (s *MyAPIDonutCacheSuite) SetUpSuite(c *C) {
httpHandler, minioAPI := getAPIHandler(api.Config{RateLimit: 16}) httpHandler, minioAPI := getAPIHandler(api.Config{RateLimit: 16})
go startTM(minioAPI) go startTM(minioAPI)
testAPIServer = httptest.NewServer(httpHandler) testAPIDonutCacheServer = httptest.NewServer(httpHandler)
} }
func (s *MyAPISuite) TearDownSuite(c *C) { func (s *MyAPIDonutCacheSuite) TearDownSuite(c *C) {
testAPIServer.Close() testAPIDonutCacheServer.Close()
} }
func setDummyAuthHeader(req *http.Request) { func setDummyAuthHeader(req *http.Request) {
@ -57,8 +55,8 @@ func setDummyAuthHeader(req *http.Request) {
req.Header.Set("Date", time.Now().UTC().Format(http.TimeFormat)) req.Header.Set("Date", time.Now().UTC().Format(http.TimeFormat))
} }
func (s *MyAPISuite) TestNonExistantBucket(c *C) { func (s *MyAPIDonutCacheSuite) TestNonExistantBucket(c *C) {
request, err := http.NewRequest("HEAD", testAPIServer.URL+"/nonexistantbucket", nil) request, err := http.NewRequest("HEAD", testAPIDonutCacheServer.URL+"/nonexistantbucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -68,8 +66,8 @@ func (s *MyAPISuite) TestNonExistantBucket(c *C) {
c.Assert(response.StatusCode, Equals, http.StatusNotFound) c.Assert(response.StatusCode, Equals, http.StatusNotFound)
} }
func (s *MyAPISuite) TestEmptyObject(c *C) { func (s *MyAPIDonutCacheSuite) TestEmptyObject(c *C) {
request, err := http.NewRequest("PUT", testAPIServer.URL+"/emptyobject", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/emptyobject", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -78,7 +76,7 @@ func (s *MyAPISuite) TestEmptyObject(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIServer.URL+"/emptyobject/object", nil) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/emptyobject/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -87,7 +85,7 @@ func (s *MyAPISuite) TestEmptyObject(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIServer.URL+"/emptyobject/object", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/emptyobject/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -102,8 +100,8 @@ func (s *MyAPISuite) TestEmptyObject(c *C) {
c.Assert(true, Equals, bytes.Equal(responseBody, buffer.Bytes())) c.Assert(true, Equals, bytes.Equal(responseBody, buffer.Bytes()))
} }
func (s *MyAPISuite) TestBucket(c *C) { func (s *MyAPIDonutCacheSuite) TestBucket(c *C) {
request, err := http.NewRequest("PUT", testAPIServer.URL+"/bucket", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/bucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -112,7 +110,7 @@ func (s *MyAPISuite) TestBucket(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("HEAD", testAPIServer.URL+"/bucket", nil) request, err = http.NewRequest("HEAD", testAPIDonutCacheServer.URL+"/bucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -122,9 +120,9 @@ func (s *MyAPISuite) TestBucket(c *C) {
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
} }
func (s *MyAPISuite) TestObject(c *C) { func (s *MyAPIDonutCacheSuite) TestObject(c *C) {
buffer := bytes.NewBufferString("hello world") buffer := bytes.NewBufferString("hello world")
request, err := http.NewRequest("PUT", testAPIServer.URL+"/testobject", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/testobject", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -133,7 +131,7 @@ func (s *MyAPISuite) TestObject(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIServer.URL+"/testobject/object", buffer) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/testobject/object", buffer)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -142,7 +140,7 @@ func (s *MyAPISuite) TestObject(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIServer.URL+"/testobject/object", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/testobject/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -157,8 +155,8 @@ func (s *MyAPISuite) TestObject(c *C) {
} }
func (s *MyAPISuite) TestMultipleObjects(c *C) { func (s *MyAPIDonutCacheSuite) TestMultipleObjects(c *C) {
request, err := http.NewRequest("PUT", testAPIServer.URL+"/multipleobjects", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/multipleobjects", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -167,7 +165,7 @@ func (s *MyAPISuite) TestMultipleObjects(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIServer.URL+"/multipleobjects/object", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/multipleobjects/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -180,7 +178,7 @@ func (s *MyAPISuite) TestMultipleObjects(c *C) {
// get object // get object
buffer1 := bytes.NewBufferString("hello one") buffer1 := bytes.NewBufferString("hello one")
request, err = http.NewRequest("PUT", testAPIServer.URL+"/multipleobjects/object1", buffer1) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/multipleobjects/object1", buffer1)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -189,7 +187,7 @@ func (s *MyAPISuite) TestMultipleObjects(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIServer.URL+"/multipleobjects/object1", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/multipleobjects/object1", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -204,7 +202,7 @@ func (s *MyAPISuite) TestMultipleObjects(c *C) {
c.Assert(true, Equals, bytes.Equal(responseBody, []byte("hello one"))) c.Assert(true, Equals, bytes.Equal(responseBody, []byte("hello one")))
buffer2 := bytes.NewBufferString("hello two") buffer2 := bytes.NewBufferString("hello two")
request, err = http.NewRequest("PUT", testAPIServer.URL+"/multipleobjects/object2", buffer2) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/multipleobjects/object2", buffer2)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -213,7 +211,7 @@ func (s *MyAPISuite) TestMultipleObjects(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIServer.URL+"/multipleobjects/object2", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/multipleobjects/object2", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -228,7 +226,7 @@ func (s *MyAPISuite) TestMultipleObjects(c *C) {
c.Assert(true, Equals, bytes.Equal(responseBody, []byte("hello two"))) c.Assert(true, Equals, bytes.Equal(responseBody, []byte("hello two")))
buffer3 := bytes.NewBufferString("hello three") buffer3 := bytes.NewBufferString("hello three")
request, err = http.NewRequest("PUT", testAPIServer.URL+"/multipleobjects/object3", buffer3) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/multipleobjects/object3", buffer3)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -237,7 +235,7 @@ func (s *MyAPISuite) TestMultipleObjects(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIServer.URL+"/multipleobjects/object3", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/multipleobjects/object3", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -252,8 +250,8 @@ func (s *MyAPISuite) TestMultipleObjects(c *C) {
c.Assert(true, Equals, bytes.Equal(responseBody, []byte("hello three"))) c.Assert(true, Equals, bytes.Equal(responseBody, []byte("hello three")))
} }
func (s *MyAPISuite) TestNotImplemented(c *C) { func (s *MyAPIDonutCacheSuite) TestNotImplemented(c *C) {
request, err := http.NewRequest("GET", testAPIServer.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) setDummyAuthHeader(request)
@ -264,8 +262,8 @@ func (s *MyAPISuite) TestNotImplemented(c *C) {
} }
func (s *MyAPISuite) TestHeader(c *C) { func (s *MyAPIDonutCacheSuite) TestHeader(c *C) {
request, err := http.NewRequest("GET", testAPIServer.URL+"/bucket/object", nil) request, err := http.NewRequest("GET", testAPIDonutCacheServer.URL+"/bucket/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -276,8 +274,8 @@ func (s *MyAPISuite) TestHeader(c *C) {
verifyError(c, response, "NoSuchKey", "The specified key does not exist.", http.StatusNotFound) verifyError(c, response, "NoSuchKey", "The specified key does not exist.", http.StatusNotFound)
} }
func (s *MyAPISuite) TestPutBucket(c *C) { func (s *MyAPIDonutCacheSuite) TestPutBucket(c *C) {
request, err := http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -288,8 +286,8 @@ func (s *MyAPISuite) TestPutBucket(c *C) {
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
} }
func (s *MyAPISuite) TestPutObject(c *C) { func (s *MyAPIDonutCacheSuite) TestPutObject(c *C) {
request, err := http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -299,7 +297,7 @@ func (s *MyAPISuite) TestPutObject(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -308,8 +306,8 @@ func (s *MyAPISuite) TestPutObject(c *C) {
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
} }
func (s *MyAPISuite) TestListBuckets(c *C) { func (s *MyAPIDonutCacheSuite) TestListBuckets(c *C) {
request, err := http.NewRequest("GET", testAPIServer.URL+"/", nil) request, err := http.NewRequest("GET", testAPIDonutCacheServer.URL+"/", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -318,19 +316,14 @@ func (s *MyAPISuite) TestListBuckets(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
_, err = readListBucket(response.Body) var results api.ListBucketsResponse
decoder := xml.NewDecoder(response.Body)
err = decoder.Decode(&results)
c.Assert(err, IsNil) c.Assert(err, IsNil)
} }
func readListBucket(reader io.Reader) (api.ListBucketsResponse, error) { func (s *MyAPIDonutCacheSuite) TestNotBeAbleToCreateObjectInNonexistantBucket(c *C) {
var results api.ListBucketsResponse request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/innonexistantbucket/object", bytes.NewBufferString("hello world"))
decoder := xml.NewDecoder(reader)
err := decoder.Decode(&results)
return results, err
}
func (s *MyAPISuite) TestNotBeAbleToCreateObjectInNonexistantBucket(c *C) {
request, err := http.NewRequest("PUT", testAPIServer.URL+"/innonexistantbucket/object", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -340,8 +333,8 @@ func (s *MyAPISuite) TestNotBeAbleToCreateObjectInNonexistantBucket(c *C) {
verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound) verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound)
} }
func (s *MyAPISuite) TestHeadOnObject(c *C) { func (s *MyAPIDonutCacheSuite) TestHeadOnObject(c *C) {
request, err := http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -351,7 +344,7 @@ func (s *MyAPISuite) TestHeadOnObject(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -359,7 +352,7 @@ func (s *MyAPISuite) TestHeadOnObject(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("HEAD", testAPIServer.URL+"/headonobject/object1", nil) request, err = http.NewRequest("HEAD", testAPIDonutCacheServer.URL+"/headonobject/object1", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -368,8 +361,8 @@ func (s *MyAPISuite) TestHeadOnObject(c *C) {
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
} }
func (s *MyAPISuite) TestHeadOnBucket(c *C) { func (s *MyAPIDonutCacheSuite) TestHeadOnBucket(c *C) {
request, err := http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -379,7 +372,7 @@ func (s *MyAPISuite) TestHeadOnBucket(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("HEAD", testAPIServer.URL+"/headonbucket", nil) request, err = http.NewRequest("HEAD", testAPIDonutCacheServer.URL+"/headonbucket", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -388,8 +381,8 @@ func (s *MyAPISuite) TestHeadOnBucket(c *C) {
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
} }
func (s *MyAPISuite) TestDateFormat(c *C) { func (s *MyAPIDonutCacheSuite) TestDateFormat(c *C) {
request, err := http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -409,22 +402,8 @@ func (s *MyAPISuite) TestDateFormat(c *C) {
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
} }
func verifyHeaders(c *C, header http.Header, date time.Time, size int, contentType string, etag string) { func (s *MyAPIDonutCacheSuite) TestXMLNameNotInBucketListJson(c *C) {
// Verify date request, err := http.NewRequest("GET", testAPIDonutCacheServer.URL+"/", nil)
c.Assert(header.Get("Last-Modified"), Equals, date.Format(http.TimeFormat))
// verify size
c.Assert(header.Get("Content-Length"), Equals, strconv.Itoa(size))
// verify content type
c.Assert(header.Get("Content-Type"), Equals, contentType)
// verify etag
c.Assert(header.Get("Etag"), Equals, "\""+etag+"\"")
}
func (s *MyAPISuite) TestXMLNameNotInBucketListJson(c *C) {
request, err := http.NewRequest("GET", testAPIServer.URL+"/", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
request.Header.Add("Accept", "application/json") request.Header.Add("Accept", "application/json")
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -439,8 +418,8 @@ func (s *MyAPISuite) TestXMLNameNotInBucketListJson(c *C) {
c.Assert(strings.Contains(string(byteResults), "XML"), Equals, false) c.Assert(strings.Contains(string(byteResults), "XML"), Equals, false)
} }
func (s *MyAPISuite) TestXMLNameNotInObjectListJson(c *C) { func (s *MyAPIDonutCacheSuite) TestXMLNameNotInObjectListJson(c *C) {
request, err := http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -450,7 +429,7 @@ func (s *MyAPISuite) TestXMLNameNotInObjectListJson(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIServer.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) setDummyAuthHeader(request)
@ -465,8 +444,8 @@ func (s *MyAPISuite) TestXMLNameNotInObjectListJson(c *C) {
c.Assert(strings.Contains(string(byteResults), "XML"), Equals, false) c.Assert(strings.Contains(string(byteResults), "XML"), Equals, false)
} }
func (s *MyAPISuite) TestContentTypePersists(c *C) { func (s *MyAPIDonutCacheSuite) TestContentTypePersists(c *C) {
request, err := http.NewRequest("PUT", testAPIServer.URL+"/contenttype-persists", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/contenttype-persists", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -475,7 +454,7 @@ func (s *MyAPISuite) TestContentTypePersists(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -485,7 +464,7 @@ func (s *MyAPISuite) TestContentTypePersists(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("HEAD", testAPIServer.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) setDummyAuthHeader(request)
@ -493,7 +472,7 @@ func (s *MyAPISuite) TestContentTypePersists(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream") c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream")
request, err = http.NewRequest("GET", testAPIServer.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) setDummyAuthHeader(request)
@ -503,7 +482,7 @@ func (s *MyAPISuite) TestContentTypePersists(c *C) {
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream") c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream")
request, err = http.NewRequest("PUT", testAPIServer.URL+"/contenttype-persists/two", bytes.NewBufferString("hello world")) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/contenttype-persists/two", bytes.NewBufferString("hello world"))
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)
@ -513,7 +492,7 @@ func (s *MyAPISuite) TestContentTypePersists(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("HEAD", testAPIServer.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) setDummyAuthHeader(request)
@ -521,7 +500,7 @@ func (s *MyAPISuite) TestContentTypePersists(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream") c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream")
request, err = http.NewRequest("GET", testAPIServer.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) setDummyAuthHeader(request)
@ -530,8 +509,8 @@ func (s *MyAPISuite) TestContentTypePersists(c *C) {
c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream") c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream")
} }
func (s *MyAPISuite) TestPartialContent(c *C) { func (s *MyAPIDonutCacheSuite) TestPartialContent(c *C) {
request, err := http.NewRequest("PUT", testAPIServer.URL+"/partial-content", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/partial-content", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -540,7 +519,7 @@ func (s *MyAPISuite) TestPartialContent(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -550,7 +529,7 @@ func (s *MyAPISuite) TestPartialContent(c *C) {
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
// prepare request // prepare request
request, err = http.NewRequest("GET", testAPIServer.URL+"/partial-content/bar", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/partial-content/bar", nil)
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")
@ -566,8 +545,8 @@ func (s *MyAPISuite) TestPartialContent(c *C) {
c.Assert(string(partialObject), Equals, "Wo") c.Assert(string(partialObject), Equals, "Wo")
} }
func (s *MyAPISuite) TestListObjectsHandlerErrors(c *C) { func (s *MyAPIDonutCacheSuite) TestListObjectsHandlerErrors(c *C) {
request, err := http.NewRequest("GET", testAPIServer.URL+"/objecthandlererrors-.", nil) request, err := http.NewRequest("GET", testAPIDonutCacheServer.URL+"/objecthandlererrors-.", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -576,7 +555,7 @@ func (s *MyAPISuite) TestListObjectsHandlerErrors(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
verifyError(c, response, "InvalidBucketName", "The specified bucket is not valid.", http.StatusBadRequest) verifyError(c, response, "InvalidBucketName", "The specified bucket is not valid.", http.StatusBadRequest)
request, err = http.NewRequest("GET", testAPIServer.URL+"/objecthandlererrors", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/objecthandlererrors", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -586,8 +565,8 @@ func (s *MyAPISuite) TestListObjectsHandlerErrors(c *C) {
verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound) verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound)
} }
func (s *MyAPISuite) TestPutBucketErrors(c *C) { func (s *MyAPIDonutCacheSuite) TestPutBucketErrors(c *C) {
request, err := http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -597,7 +576,7 @@ func (s *MyAPISuite) TestPutBucketErrors(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
verifyError(c, response, "InvalidBucketName", "The specified bucket is not valid.", http.StatusBadRequest) verifyError(c, response, "InvalidBucketName", "The specified bucket is not valid.", http.StatusBadRequest)
request, err = http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -607,7 +586,7 @@ func (s *MyAPISuite) TestPutBucketErrors(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -616,7 +595,7 @@ func (s *MyAPISuite) TestPutBucketErrors(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
verifyError(c, response, "BucketAlreadyExists", "The requested bucket name is not available.", http.StatusConflict) verifyError(c, response, "BucketAlreadyExists", "The requested bucket name is not available.", http.StatusConflict)
request, err = http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -626,8 +605,8 @@ func (s *MyAPISuite) TestPutBucketErrors(c *C) {
verifyError(c, response, "NotImplemented", "A header you provided implies functionality that is not implemented.", http.StatusNotImplemented) verifyError(c, response, "NotImplemented", "A header you provided implies functionality that is not implemented.", http.StatusNotImplemented)
} }
func (s *MyAPISuite) TestGetObjectErrors(c *C) { func (s *MyAPIDonutCacheSuite) TestGetObjectErrors(c *C) {
request, err := http.NewRequest("GET", testAPIServer.URL+"/getobjecterrors", nil) request, err := http.NewRequest("GET", testAPIDonutCacheServer.URL+"/getobjecterrors", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -636,7 +615,7 @@ func (s *MyAPISuite) TestGetObjectErrors(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound) verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound)
request, err = http.NewRequest("PUT", testAPIServer.URL+"/getobjecterrors", nil) request, err = http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/getobjecterrors", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -645,7 +624,7 @@ func (s *MyAPISuite) TestGetObjectErrors(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIServer.URL+"/getobjecterrors/bar", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/getobjecterrors/bar", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -654,7 +633,7 @@ func (s *MyAPISuite) TestGetObjectErrors(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
verifyError(c, response, "NoSuchKey", "The specified key does not exist.", http.StatusNotFound) verifyError(c, response, "NoSuchKey", "The specified key does not exist.", http.StatusNotFound)
request, err = http.NewRequest("GET", testAPIServer.URL+"/getobjecterrors-./bar", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/getobjecterrors-./bar", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -664,8 +643,8 @@ func (s *MyAPISuite) TestGetObjectErrors(c *C) {
} }
func (s *MyAPISuite) TestGetObjectRangeErrors(c *C) { func (s *MyAPIDonutCacheSuite) TestGetObjectRangeErrors(c *C) {
request, err := http.NewRequest("PUT", testAPIServer.URL+"/getobjectrangeerrors", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/getobjectrangeerrors", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -674,7 +653,7 @@ func (s *MyAPISuite) TestGetObjectRangeErrors(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -683,7 +662,7 @@ func (s *MyAPISuite) TestGetObjectRangeErrors(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIServer.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) setDummyAuthHeader(request)
@ -694,8 +673,8 @@ func (s *MyAPISuite) TestGetObjectRangeErrors(c *C) {
verifyError(c, response, "InvalidRange", "The requested range cannot be satisfied.", http.StatusRequestedRangeNotSatisfiable) verifyError(c, response, "InvalidRange", "The requested range cannot be satisfied.", http.StatusRequestedRangeNotSatisfiable)
} }
func (s *MyAPISuite) TestObjectMultipartAbort(c *C) { func (s *MyAPIDonutCacheSuite) TestObjectMultipartAbort(c *C) {
request, err := http.NewRequest("PUT", testAPIServer.URL+"/objectmultipartabort", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultipartabort", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -704,7 +683,7 @@ func (s *MyAPISuite) TestObjectMultipartAbort(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, 200) c.Assert(response.StatusCode, Equals, 200)
request, err = http.NewRequest("POST", testAPIServer.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) setDummyAuthHeader(request)
@ -719,7 +698,7 @@ func (s *MyAPISuite) TestObjectMultipartAbort(c *C) {
c.Assert(len(newResponse.UploadID) > 0, Equals, true) c.Assert(len(newResponse.UploadID) > 0, Equals, true)
uploadID := newResponse.UploadID uploadID := newResponse.UploadID
request, err = http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -727,7 +706,7 @@ func (s *MyAPISuite) TestObjectMultipartAbort(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response1.StatusCode, Equals, http.StatusOK) c.Assert(response1.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -735,7 +714,7 @@ func (s *MyAPISuite) TestObjectMultipartAbort(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response2.StatusCode, Equals, http.StatusOK) c.Assert(response2.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("DELETE", testAPIServer.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) setDummyAuthHeader(request)
@ -744,8 +723,8 @@ func (s *MyAPISuite) TestObjectMultipartAbort(c *C) {
c.Assert(response3.StatusCode, Equals, http.StatusNoContent) c.Assert(response3.StatusCode, Equals, http.StatusNoContent)
} }
func (s *MyAPISuite) TestBucketMultipartList(c *C) { func (s *MyAPIDonutCacheSuite) TestBucketMultipartList(c *C) {
request, err := http.NewRequest("PUT", testAPIServer.URL+"/bucketmultipartlist", bytes.NewBufferString("")) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/bucketmultipartlist", bytes.NewBufferString(""))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -754,7 +733,7 @@ func (s *MyAPISuite) TestBucketMultipartList(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, 200) c.Assert(response.StatusCode, Equals, 200)
request, err = http.NewRequest("POST", testAPIServer.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) setDummyAuthHeader(request)
@ -769,7 +748,7 @@ func (s *MyAPISuite) TestBucketMultipartList(c *C) {
c.Assert(len(newResponse.UploadID) > 0, Equals, true) c.Assert(len(newResponse.UploadID) > 0, Equals, true)
uploadID := newResponse.UploadID uploadID := newResponse.UploadID
request, err = http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -777,7 +756,7 @@ func (s *MyAPISuite) TestBucketMultipartList(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response1.StatusCode, Equals, http.StatusOK) c.Assert(response1.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -785,7 +764,7 @@ func (s *MyAPISuite) TestBucketMultipartList(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response2.StatusCode, Equals, http.StatusOK) c.Assert(response2.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIServer.URL+"/bucketmultipartlist?uploads", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/bucketmultipartlist?uploads", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -800,8 +779,8 @@ func (s *MyAPISuite) TestBucketMultipartList(c *C) {
c.Assert(newResponse3.Bucket, Equals, "bucketmultipartlist") c.Assert(newResponse3.Bucket, Equals, "bucketmultipartlist")
} }
func (s *MyAPISuite) TestObjectMultipartList(c *C) { func (s *MyAPIDonutCacheSuite) TestObjectMultipartList(c *C) {
request, err := http.NewRequest("PUT", testAPIServer.URL+"/objectmultipartlist", bytes.NewBufferString("")) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultipartlist", bytes.NewBufferString(""))
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -810,7 +789,7 @@ func (s *MyAPISuite) TestObjectMultipartList(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, 200) c.Assert(response.StatusCode, Equals, 200)
request, err = http.NewRequest("POST", testAPIServer.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) setDummyAuthHeader(request)
@ -825,7 +804,7 @@ func (s *MyAPISuite) TestObjectMultipartList(c *C) {
c.Assert(len(newResponse.UploadID) > 0, Equals, true) c.Assert(len(newResponse.UploadID) > 0, Equals, true)
uploadID := newResponse.UploadID uploadID := newResponse.UploadID
request, err = http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -833,7 +812,7 @@ func (s *MyAPISuite) TestObjectMultipartList(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response1.StatusCode, Equals, http.StatusOK) c.Assert(response1.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -841,7 +820,7 @@ func (s *MyAPISuite) TestObjectMultipartList(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response2.StatusCode, Equals, http.StatusOK) c.Assert(response2.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIServer.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) setDummyAuthHeader(request)
@ -851,8 +830,8 @@ func (s *MyAPISuite) TestObjectMultipartList(c *C) {
} }
func (s *MyAPISuite) TestObjectMultipart(c *C) { func (s *MyAPIDonutCacheSuite) TestObjectMultipart(c *C) {
request, err := http.NewRequest("PUT", testAPIServer.URL+"/objectmultiparts", nil) request, err := http.NewRequest("PUT", testAPIDonutCacheServer.URL+"/objectmultiparts", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)
@ -861,7 +840,7 @@ func (s *MyAPISuite) TestObjectMultipart(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, 200) c.Assert(response.StatusCode, Equals, 200)
request, err = http.NewRequest("POST", testAPIServer.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) setDummyAuthHeader(request)
@ -878,7 +857,7 @@ func (s *MyAPISuite) TestObjectMultipart(c *C) {
c.Assert(len(newResponse.UploadID) > 0, Equals, true) c.Assert(len(newResponse.UploadID) > 0, Equals, true)
uploadID := newResponse.UploadID uploadID := newResponse.UploadID
request, err = http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -887,7 +866,7 @@ func (s *MyAPISuite) TestObjectMultipart(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response1.StatusCode, Equals, http.StatusOK) c.Assert(response1.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIServer.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) setDummyAuthHeader(request)
@ -914,7 +893,7 @@ func (s *MyAPISuite) TestObjectMultipart(c *C) {
encoder := xml.NewEncoder(&completeBuffer) encoder := xml.NewEncoder(&completeBuffer)
encoder.Encode(completeUploads) encoder.Encode(completeUploads)
request, err = http.NewRequest("POST", testAPIServer.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) setDummyAuthHeader(request)
@ -922,7 +901,7 @@ func (s *MyAPISuite) TestObjectMultipart(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK) c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIServer.URL+"/objectmultiparts/object", nil) request, err = http.NewRequest("GET", testAPIDonutCacheServer.URL+"/objectmultiparts/object", nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
setDummyAuthHeader(request) setDummyAuthHeader(request)

View File

@ -0,0 +1,944 @@
/*
* Minimalist Object Storage, (C) 2014 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 server
import (
"bytes"
"io/ioutil"
"os"
"path/filepath"
"strconv"
"strings"
"testing"
"time"
"encoding/xml"
"net/http"
"net/http/httptest"
. "github.com/minio/check"
"github.com/minio/minio/pkg/donut"
"github.com/minio/minio/pkg/server/api"
)
func TestAPIDonut(t *testing.T) { TestingT(t) }
type MyAPIDonutSuite struct {
root string
}
var _ = Suite(&MyAPIDonutSuite{})
var testAPIDonutServer *httptest.Server
// create a dummy TestNodeDiskMap
func createTestNodeDiskMap(p string) map[string][]string {
nodes := make(map[string][]string)
nodes["localhost"] = make([]string, 16)
for i := 0; i < len(nodes["localhost"]); i++ {
diskPath := filepath.Join(p, strconv.Itoa(i))
if _, err := os.Stat(diskPath); err != nil {
if os.IsNotExist(err) {
os.MkdirAll(diskPath, 0700)
}
}
nodes["localhost"][i] = diskPath
}
return nodes
}
func (s *MyAPIDonutSuite) SetUpSuite(c *C) {
root, err := ioutil.TempDir(os.TempDir(), "api-")
c.Assert(err, IsNil)
s.root = root
conf := new(donut.Config)
conf.Version = "0.0.1"
conf.DonutName = "test"
conf.NodeDiskMap = createTestNodeDiskMap(root)
conf.MaxSize = 100000
donut.CustomConfigPath = filepath.Join(root, "donut.json")
err = donut.SaveConfig(conf)
c.Assert(err, IsNil)
httpHandler, minioAPI := getAPIHandler(api.Config{RateLimit: 16})
go startTM(minioAPI)
testAPIDonutServer = httptest.NewServer(httpHandler)
}
func (s *MyAPIDonutSuite) TearDownSuite(c *C) {
os.RemoveAll(s.root)
testAPIDonutServer.Close()
}
func (s *MyAPIDonutSuite) TestNonExistantBucket(c *C) {
request, err := http.NewRequest("HEAD", testAPIDonutServer.URL+"/nonexistantbucket", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusNotFound)
}
func (s *MyAPIDonutSuite) TestEmptyObject(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/emptyobject", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/emptyobject/object", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/emptyobject/object", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
var buffer bytes.Buffer
responseBody, err := ioutil.ReadAll(response.Body)
c.Assert(err, IsNil)
c.Assert(true, Equals, bytes.Equal(responseBody, buffer.Bytes()))
}
func (s *MyAPIDonutSuite) TestBucket(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/bucket", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("HEAD", testAPIDonutServer.URL+"/bucket", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
}
func (s *MyAPIDonutSuite) TestObject(c *C) {
buffer := bytes.NewBufferString("hello world")
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/testobject", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/testobject/object", buffer)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/testobject/object", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
responseBody, err := ioutil.ReadAll(response.Body)
c.Assert(err, IsNil)
c.Assert(responseBody, DeepEquals, []byte("hello world"))
}
func (s *MyAPIDonutSuite) TestMultipleObjects(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/multipleobjects", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/multipleobjects/object", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
verifyError(c, response, "NoSuchKey", "The specified key does not exist.", http.StatusNotFound)
//// test object 1
// get object
buffer1 := bytes.NewBufferString("hello one")
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/multipleobjects/object1", buffer1)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/multipleobjects/object1", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
// verify response data
responseBody, err := ioutil.ReadAll(response.Body)
c.Assert(err, IsNil)
c.Assert(true, Equals, bytes.Equal(responseBody, []byte("hello one")))
buffer2 := bytes.NewBufferString("hello two")
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/multipleobjects/object2", buffer2)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/multipleobjects/object2", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
// verify response data
responseBody, err = ioutil.ReadAll(response.Body)
c.Assert(err, IsNil)
c.Assert(true, Equals, bytes.Equal(responseBody, []byte("hello two")))
buffer3 := bytes.NewBufferString("hello three")
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/multipleobjects/object3", buffer3)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/multipleobjects/object3", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
// verify object
responseBody, err = ioutil.ReadAll(response.Body)
c.Assert(err, IsNil)
c.Assert(true, Equals, bytes.Equal(responseBody, []byte("hello three")))
}
func (s *MyAPIDonutSuite) TestNotImplemented(c *C) {
request, err := http.NewRequest("GET", testAPIDonutServer.URL+"/bucket/object?policy", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusNotImplemented)
}
func (s *MyAPIDonutSuite) TestHeader(c *C) {
request, err := http.NewRequest("GET", testAPIDonutServer.URL+"/bucket/object", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
verifyError(c, response, "NoSuchKey", "The specified key does not exist.", http.StatusNotFound)
}
func (s *MyAPIDonutSuite) TestPutBucket(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/put-bucket", nil)
c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
}
func (s *MyAPIDonutSuite) TestPutObject(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/put-object", nil)
c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/put-object/object", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
}
func (s *MyAPIDonutSuite) TestListBuckets(c *C) {
request, err := http.NewRequest("GET", testAPIDonutServer.URL+"/", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
var results api.ListBucketsResponse
decoder := xml.NewDecoder(response.Body)
err = decoder.Decode(&results)
c.Assert(err, IsNil)
}
func (s *MyAPIDonutSuite) TestNotBeAbleToCreateObjectInNonexistantBucket(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/innonexistantbucket/object", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound)
}
func (s *MyAPIDonutSuite) TestHeadOnObject(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/headonobject", nil)
c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/headonobject/object1", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("HEAD", testAPIDonutServer.URL+"/headonobject/object1", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
}
func (s *MyAPIDonutSuite) TestHeadOnBucket(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/headonbucket", nil)
c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("HEAD", testAPIDonutServer.URL+"/headonbucket", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
}
func (s *MyAPIDonutSuite) TestDateFormat(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/dateformat", nil)
c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
// set an invalid date
request.Header.Set("Date", "asfasdfadf")
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
verifyError(c, response, "RequestTimeTooSkewed",
"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))
setDummyAuthHeader(request)
response, err = client.Do(request)
c.Assert(response.StatusCode, Equals, http.StatusOK)
}
func (s *MyAPIDonutSuite) TestXMLNameNotInBucketListJson(c *C) {
request, err := http.NewRequest("GET", testAPIDonutServer.URL+"/", nil)
c.Assert(err, IsNil)
request.Header.Add("Accept", "application/json")
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
byteResults, err := ioutil.ReadAll(response.Body)
c.Assert(err, IsNil)
c.Assert(strings.Contains(string(byteResults), "XML"), Equals, false)
}
func (s *MyAPIDonutSuite) TestXMLNameNotInObjectListJson(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/xmlnamenotinobjectlistjson", nil)
c.Assert(err, IsNil)
request.Header.Add("Accept", "application/json")
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/xmlnamenotinobjectlistjson", nil)
c.Assert(err, IsNil)
request.Header.Add("Accept", "application/json")
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
byteResults, err := ioutil.ReadAll(response.Body)
c.Assert(err, IsNil)
c.Assert(strings.Contains(string(byteResults), "XML"), Equals, false)
}
func (s *MyAPIDonutSuite) TestContentTypePersists(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/contenttype-persists", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/contenttype-persists/one", bytes.NewBufferString("hello world"))
delete(request.Header, "Content-Type")
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("HEAD", testAPIDonutServer.URL+"/contenttype-persists/one", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream")
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/contenttype-persists/one", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream")
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/contenttype-persists/two", bytes.NewBufferString("hello world"))
delete(request.Header, "Content-Type")
request.Header.Add("Content-Type", "application/json")
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("HEAD", testAPIDonutServer.URL+"/contenttype-persists/two", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream")
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/contenttype-persists/two", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream")
}
func (s *MyAPIDonutSuite) TestPartialContent(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/partial-content", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/partial-content/bar", bytes.NewBufferString("Hello World"))
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
// prepare request
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/partial-content/bar", nil)
c.Assert(err, IsNil)
request.Header.Add("Accept", "application/json")
request.Header.Add("Range", "bytes=6-7")
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusPartialContent)
partialObject, err := ioutil.ReadAll(response.Body)
c.Assert(err, IsNil)
c.Assert(string(partialObject), Equals, "Wo")
}
func (s *MyAPIDonutSuite) TestListObjectsHandlerErrors(c *C) {
request, err := http.NewRequest("GET", testAPIDonutServer.URL+"/objecthandlererrors-.", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
verifyError(c, response, "InvalidBucketName", "The specified bucket is not valid.", http.StatusBadRequest)
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/objecthandlererrors", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound)
}
func (s *MyAPIDonutSuite) TestPutBucketErrors(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/putbucket-.", nil)
c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
verifyError(c, response, "InvalidBucketName", "The specified bucket is not valid.", http.StatusBadRequest)
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/putbucket", nil)
c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/putbucket", nil)
c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "private")
setDummyAuthHeader(request)
response, err = client.Do(request)
c.Assert(err, IsNil)
verifyError(c, response, "BucketAlreadyExists", "The requested bucket name is not available.", http.StatusConflict)
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/putbucket?acl", nil)
c.Assert(err, IsNil)
request.Header.Add("x-amz-acl", "unknown")
setDummyAuthHeader(request)
response, err = client.Do(request)
c.Assert(err, IsNil)
verifyError(c, response, "NotImplemented", "A header you provided implies functionality that is not implemented.", http.StatusNotImplemented)
}
func (s *MyAPIDonutSuite) TestGetObjectErrors(c *C) {
request, err := http.NewRequest("GET", testAPIDonutServer.URL+"/getobjecterrors", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound)
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/getobjecterrors", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/getobjecterrors/bar", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
verifyError(c, response, "NoSuchKey", "The specified key does not exist.", http.StatusNotFound)
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/getobjecterrors-./bar", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request)
c.Assert(err, IsNil)
verifyError(c, response, "InvalidBucketName", "The specified bucket is not valid.", http.StatusBadRequest)
}
func (s *MyAPIDonutSuite) TestGetObjectRangeErrors(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/getobjectrangeerrors", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/getobjectrangeerrors/bar", bytes.NewBufferString("Hello World"))
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/getobjectrangeerrors/bar", nil)
request.Header.Add("Range", "bytes=7-6")
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
verifyError(c, response, "InvalidRange", "The requested range cannot be satisfied.", http.StatusRequestedRangeNotSatisfiable)
}
func (s *MyAPIDonutSuite) TestObjectMultipartAbort(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultipartabort", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, 200)
request, err = http.NewRequest("POST", testAPIDonutServer.URL+"/objectmultipartabort/object?uploads", bytes.NewBufferString(""))
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request)
c.Assert(response.StatusCode, Equals, http.StatusOK)
decoder := xml.NewDecoder(response.Body)
newResponse := &api.InitiateMultipartUploadResult{}
err = decoder.Decode(newResponse)
c.Assert(err, IsNil)
c.Assert(len(newResponse.UploadID) > 0, Equals, true)
uploadID := newResponse.UploadID
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultipartabort/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response1, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response1.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultipartabort/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response2, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response2.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("DELETE", testAPIDonutServer.URL+"/objectmultipartabort/object?uploadId="+uploadID, nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response3, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response3.StatusCode, Equals, http.StatusNoContent)
}
func (s *MyAPIDonutSuite) TestBucketMultipartList(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/bucketmultipartlist", bytes.NewBufferString(""))
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, 200)
request, err = http.NewRequest("POST", testAPIDonutServer.URL+"/bucketmultipartlist/object?uploads", bytes.NewBufferString(""))
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request)
c.Assert(response.StatusCode, Equals, http.StatusOK)
decoder := xml.NewDecoder(response.Body)
newResponse := &api.InitiateMultipartUploadResult{}
err = decoder.Decode(newResponse)
c.Assert(err, IsNil)
c.Assert(len(newResponse.UploadID) > 0, Equals, true)
uploadID := newResponse.UploadID
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/bucketmultipartlist/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response1, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response1.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/bucketmultipartlist/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response2, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response2.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/bucketmultipartlist?uploads", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response3, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response3.StatusCode, Equals, http.StatusOK)
decoder = xml.NewDecoder(response3.Body)
newResponse3 := &api.ListMultipartUploadsResponse{}
err = decoder.Decode(newResponse3)
c.Assert(err, IsNil)
c.Assert(newResponse3.Bucket, Equals, "bucketmultipartlist")
}
func (s *MyAPIDonutSuite) TestObjectMultipartList(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultipartlist", bytes.NewBufferString(""))
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, 200)
request, err = http.NewRequest("POST", testAPIDonutServer.URL+"/objectmultipartlist/object?uploads", bytes.NewBufferString(""))
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request)
c.Assert(response.StatusCode, Equals, http.StatusOK)
decoder := xml.NewDecoder(response.Body)
newResponse := &api.InitiateMultipartUploadResult{}
err = decoder.Decode(newResponse)
c.Assert(err, IsNil)
c.Assert(len(newResponse.UploadID) > 0, Equals, true)
uploadID := newResponse.UploadID
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultipartlist/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response1, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response1.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultipartlist/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response2, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response2.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/objectmultipartlist/object?uploadId="+uploadID, nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response3, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response3.StatusCode, Equals, http.StatusOK)
}
func (s *MyAPIDonutSuite) TestObjectMultipart(c *C) {
request, err := http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultiparts", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, 200)
request, err = http.NewRequest("POST", testAPIDonutServer.URL+"/objectmultiparts/object?uploads", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
decoder := xml.NewDecoder(response.Body)
newResponse := &api.InitiateMultipartUploadResult{}
err = decoder.Decode(newResponse)
c.Assert(err, IsNil)
c.Assert(len(newResponse.UploadID) > 0, Equals, true)
uploadID := newResponse.UploadID
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultiparts/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response1, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response1.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("PUT", testAPIDonutServer.URL+"/objectmultiparts/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
c.Assert(err, IsNil)
setDummyAuthHeader(request)
client = http.Client{}
response2, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response2.StatusCode, Equals, http.StatusOK)
// complete multipart upload
completeUploads := &api.CompleteMultipartUpload{
Part: []api.Part{
{
PartNumber: 1,
ETag: response1.Header.Get("ETag"),
},
{
PartNumber: 2,
ETag: response2.Header.Get("ETag"),
},
},
}
var completeBuffer bytes.Buffer
encoder := xml.NewEncoder(&completeBuffer)
encoder.Encode(completeUploads)
request, err = http.NewRequest("POST", testAPIDonutServer.URL+"/objectmultiparts/object?uploadId="+uploadID, &completeBuffer)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
request, err = http.NewRequest("GET", testAPIDonutServer.URL+"/objectmultiparts/object", nil)
c.Assert(err, IsNil)
setDummyAuthHeader(request)
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
object, err := ioutil.ReadAll(response.Body)
c.Assert(err, IsNil)
c.Assert(string(object), Equals, ("hello worldhello world"))
}