|
|
|
@ -123,6 +123,12 @@ func setDummyAuthHeader(req *http.Request) { |
|
|
|
|
req.Header.Set("Date", time.Now().UTC().Format(http.TimeFormat)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func setConfig(driver drivers.Driver) Config { |
|
|
|
|
conf := Config{ConnectionLimit: 16} |
|
|
|
|
conf.SetDriver(driver) |
|
|
|
|
return conf |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (s *MySuite) TestNonExistantBucket(c *C) { |
|
|
|
|
switch driver := s.Driver.(type) { |
|
|
|
|
case *mocks.Driver: |
|
|
|
@ -131,7 +137,7 @@ func (s *MySuite) TestNonExistantBucket(c *C) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
driver := s.Driver |
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
|
|
|
|
@ -169,7 +175,7 @@ func (s *MySuite) TestEmptyObject(c *C) { |
|
|
|
|
typedDriver.On("GetObjectMetadata", "bucket", "object").Return(metadata, nil).Once() |
|
|
|
|
typedDriver.On("GetObject", mock.Anything, "bucket", "object").Return(int64(0), nil).Once() |
|
|
|
|
typedDriver.On("GetObjectMetadata", "bucket", "object").Return(metadata, nil).Once() |
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
|
|
|
|
@ -212,7 +218,7 @@ func (s *MySuite) TestBucket(c *C) { |
|
|
|
|
typedDriver.On("CreateBucket", "bucket", "private").Return(nil).Once() |
|
|
|
|
typedDriver.On("GetBucketMetadata", "bucket").Return(metadata, nil).Once() |
|
|
|
|
|
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
|
|
|
|
@ -252,7 +258,7 @@ func (s *MySuite) TestObject(c *C) { |
|
|
|
|
typedDriver.SetGetObjectWriter("bucket", "object", []byte("hello world")) |
|
|
|
|
typedDriver.On("GetObject", mock.Anything, "bucket", "object").Return(int64(0), nil).Once() |
|
|
|
|
|
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
|
|
|
|
@ -311,7 +317,7 @@ func (s *MySuite) TestMultipleObjects(c *C) { |
|
|
|
|
Md5: "4e74ad3b92e2843e208a13ae1cf0d52c", |
|
|
|
|
Size: 11, |
|
|
|
|
} |
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
|
|
|
|
@ -441,7 +447,7 @@ func (s *MySuite) TestNotImplemented(c *C) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
driver := s.Driver |
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
|
|
|
|
@ -466,7 +472,7 @@ func (s *MySuite) TestHeader(c *C) { |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
typedDriver.AssertExpectations(c) |
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
|
|
|
|
@ -535,7 +541,7 @@ func (s *MySuite) TestPutBucket(c *C) { |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
|
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
|
|
|
|
@ -572,7 +578,7 @@ func (s *MySuite) TestPutObject(c *C) { |
|
|
|
|
} |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
|
|
|
|
@ -661,7 +667,7 @@ func (s *MySuite) TestListBuckets(c *C) { |
|
|
|
|
} |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
|
|
|
|
@ -754,7 +760,7 @@ func (s *MySuite) TestNotBeAbleToCreateObjectInNonexistantBucket(c *C) { |
|
|
|
|
} |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
|
|
|
|
@ -788,7 +794,7 @@ func (s *MySuite) TestHeadOnObject(c *C) { |
|
|
|
|
} |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
|
|
|
|
@ -842,7 +848,7 @@ func (s *MySuite) TestHeadOnBucket(c *C) { |
|
|
|
|
} |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
|
|
|
|
@ -876,7 +882,7 @@ func (s *MySuite) TestDateFormat(c *C) { |
|
|
|
|
} |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
|
|
|
|
@ -924,7 +930,7 @@ func (s *MySuite) TestXMLNameNotInBucketListJson(c *C) { |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
|
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
|
|
|
|
@ -957,7 +963,7 @@ func (s *MySuite) TestXMLNameNotInObjectListJson(c *C) { |
|
|
|
|
} |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
|
|
|
|
@ -1002,7 +1008,7 @@ func (s *MySuite) TestContentTypePersists(c *C) { |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
|
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
|
|
|
|
@ -1117,7 +1123,7 @@ func (s *MySuite) TestPartialContent(c *C) { |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
|
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
|
|
|
|
@ -1175,7 +1181,7 @@ func (s *MySuite) TestListObjectsHandlerErrors(c *C) { |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
|
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
client := http.Client{} |
|
|
|
@ -1242,7 +1248,7 @@ func (s *MySuite) TestListBucketsErrors(c *C) { |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
|
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
client := http.Client{} |
|
|
|
@ -1279,7 +1285,7 @@ func (s *MySuite) TestPutBucketErrors(c *C) { |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
|
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
client := http.Client{} |
|
|
|
@ -1339,7 +1345,7 @@ func (s *MySuite) TestGetObjectErrors(c *C) { |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
|
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
client := http.Client{} |
|
|
|
@ -1412,7 +1418,7 @@ func (s *MySuite) TestGetObjectRangeErrors(c *C) { |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
|
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
client := http.Client{} |
|
|
|
@ -1456,7 +1462,7 @@ func (s *MySuite) TestObjectMultipartAbort(c *C) { |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
|
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
client := http.Client{} |
|
|
|
@ -1539,7 +1545,7 @@ func (s *MySuite) TestBucketMultipartList(c *C) { |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
|
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
client := http.Client{} |
|
|
|
@ -1628,7 +1634,7 @@ func (s *MySuite) TestObjectMultipartList(c *C) { |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
|
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
client := http.Client{} |
|
|
|
@ -1712,7 +1718,7 @@ func (s *MySuite) TestObjectMultipart(c *C) { |
|
|
|
|
driver := s.Driver |
|
|
|
|
typedDriver := s.MockDriver |
|
|
|
|
|
|
|
|
|
httpHandler := HTTPHandler(driver) |
|
|
|
|
httpHandler := HTTPHandler(setConfig(driver)) |
|
|
|
|
testServer := httptest.NewServer(httpHandler) |
|
|
|
|
defer testServer.Close() |
|
|
|
|
client := http.Client{} |
|
|
|
|