Listen bucket notification for multiple prefixes/suffixes (#2911)

* Listen bucket notification for multiple prefixes/suffixes

* After review fixes
This commit is contained in:
Mateusz Gajewski
2016-10-12 20:02:15 +02:00
committed by Harshavardhana
parent 6199aa0707
commit 73982c8cb6
5 changed files with 74 additions and 19 deletions

View File

@@ -235,24 +235,24 @@ func testListenBucketNotificationHandler(obj ObjectLayer, instanceType string, t
invalidEvents := []string{"invalidEvent"}
testCases := []struct {
bucketName string
prefix string
suffix string
prefixes []string
suffixes []string
events []string
kind testKind
expectedHTTPCode int
expectedAPIError string
}{
// FIXME: Need to find a way to run valid listen bucket notification test case without blocking the unit test.
{randBucket, "", "", invalidEvents, CheckStatus, signatureMismatchError.HTTPStatusCode, ""},
{randBucket, tooBigPrefix, "", validEvents, CheckStatus, http.StatusBadRequest, ""},
{invalidBucket, "", "", validEvents, CheckStatus, http.StatusBadRequest, ""},
{randBucket, "", "", validEvents, InvalidAuth, signatureMismatchError.HTTPStatusCode, signatureMismatchError.Code},
{randBucket, []string{}, []string{}, invalidEvents, CheckStatus, signatureMismatchError.HTTPStatusCode, ""},
{randBucket, []string{tooBigPrefix}, []string{}, validEvents, CheckStatus, http.StatusBadRequest, ""},
{invalidBucket, []string{}, []string{}, validEvents, CheckStatus, http.StatusBadRequest, ""},
{randBucket, []string{}, []string{}, validEvents, InvalidAuth, signatureMismatchError.HTTPStatusCode, signatureMismatchError.Code},
}
for i, test := range testCases {
testRec = httptest.NewRecorder()
testReq, tErr = newTestSignedRequestV4("GET",
getListenBucketNotificationURL("", test.bucketName, test.prefix, test.suffix, test.events),
getListenBucketNotificationURL("", test.bucketName, test.prefixes, test.suffixes, test.events),
0, nil, credentials.AccessKeyID, credentials.SecretAccessKey)
if tErr != nil {
t.Fatalf("%s: Failed to create HTTP testRequest for ListenBucketNotification: <ERROR> %v", instanceType, tErr)
@@ -301,7 +301,7 @@ func testListenBucketNotificationHandler(obj ObjectLayer, instanceType string, t
})
testRec = httptest.NewRecorder()
testReq, tErr = newTestSignedRequestV4("GET",
getListenBucketNotificationURL("", randBucket, "", "*.jpg", []string{"s3:ObjectCreated:*", "s3:ObjectRemoved:*"}),
getListenBucketNotificationURL("", randBucket, []string{}, []string{"*.jpg"}, []string{"s3:ObjectCreated:*", "s3:ObjectRemoved:*"}),
0, nil, credentials.AccessKeyID, credentials.SecretAccessKey)
if tErr != nil {
t.Fatalf("%s: Failed to create HTTP testRequest for ListenBucketNotification: <ERROR> %v", instanceType, tErr)