diff --git a/cmd/server_test.go b/cmd/server_test.go
index 241633a24..72a8fe46d 100644
--- a/cmd/server_test.go
+++ b/cmd/server_test.go
@@ -75,8 +75,38 @@ func (s *TestSuiteCommon) TestAuth(c *C) {
c.Assert(len(accessID), Equals, minioAccessID)
}
+func (s *TestSuiteCommon) TestBucketSQSNotification(c *C) {
+ // Sample bucket notification.
+ bucketNotificationBuf := `s3:ObjectCreated:Putprefiximages/1arn:minio:sqs:us-east-1:444455556666:amqp`
+ // generate a random bucket Name.
+ bucketName := getRandomBucketName()
+ // HTTP request to create the bucket.
+ request, err := newTestSignedRequest("PUT", getMakeBucketURL(s.endPoint, bucketName),
+ 0, nil, s.accessKey, s.secretKey)
+ c.Assert(err, IsNil)
+
+ client := http.Client{}
+ // execute the request.
+ response, err := client.Do(request)
+ c.Assert(err, IsNil)
+
+ // assert the http response status code.
+ c.Assert(response.StatusCode, Equals, http.StatusOK)
+
+ request, err = newTestSignedRequest("PUT", getPutNotificationURL(s.endPoint, bucketName),
+ int64(len(bucketNotificationBuf)), bytes.NewReader([]byte(bucketNotificationBuf)), s.accessKey, s.secretKey)
+ c.Assert(err, IsNil)
+
+ client = http.Client{}
+ // execute the HTTP request.
+ response, err = client.Do(request)
+
+ c.Assert(err, IsNil)
+ verifyError(c, response, "InvalidArgument", "A specified destination ARN does not exist or is not well-formed. Verify the destination ARN.", http.StatusBadRequest)
+}
+
// TestBucketNotification - Inserts the bucket notification and verifies it by fetching the notification back.
-func (s *TestSuiteCommon) TestBucketNotification(c *C) {
+func (s *TestSuiteCommon) TestBucketSNSNotification(c *C) {
// Sample bucket notification.
bucketNotificationBuf := `s3:ObjectCreated:Putprefiximages/1arn:minio:sns:us-east-1:444455556666:listen`
@@ -120,7 +150,7 @@ func (s *TestSuiteCommon) TestBucketNotification(c *C) {
// Verify if downloaded policy matches with previousy uploaded.
c.Assert(bytes.Equal([]byte(bucketNotificationBuf), bucketNotificationReadBuf), Equals, true)
- invalidBucketNotificationBuf := `s3:ObjectCreated:Putprefiximages/1arn:minio:sns:us-east-1:444455556666:minio`
+ invalidBucketNotificationBuf := `s3:ObjectCreated:Putinvalidimages/1arn:minio:sns:us-east-1:444455556666:minio`
request, err = newTestSignedRequest("PUT", getPutNotificationURL(s.endPoint, bucketName),
int64(len(invalidBucketNotificationBuf)), bytes.NewReader([]byte(invalidBucketNotificationBuf)), s.accessKey, s.secretKey)
@@ -133,6 +163,32 @@ func (s *TestSuiteCommon) TestBucketNotification(c *C) {
verifyError(c, response, "InvalidArgument", "A specified destination ARN does not exist or is not well-formed. Verify the destination ARN.", http.StatusBadRequest)
+ invalidBucketNotificationBuf = `s3:ObjectCreated:Putinvalidimages/1arn:minio:sns:us-east-1:1:listen`
+
+ request, err = newTestSignedRequest("PUT", getPutNotificationURL(s.endPoint, bucketName),
+ int64(len(invalidBucketNotificationBuf)), bytes.NewReader([]byte(invalidBucketNotificationBuf)), s.accessKey, s.secretKey)
+ c.Assert(err, IsNil)
+
+ client = http.Client{}
+ // execute the HTTP request.
+ response, err = client.Do(request)
+ c.Assert(err, IsNil)
+
+ verifyError(c, response, "InvalidArgument", "filter rule name must be either prefix or suffix", http.StatusBadRequest)
+
+ invalidBucketNotificationBuf = `s3:ObjectCreated:Putprefix|||1arn:minio:sns:us-east-1:1:listen`
+
+ request, err = newTestSignedRequest("PUT", getPutNotificationURL(s.endPoint, bucketName),
+ int64(len(invalidBucketNotificationBuf)), bytes.NewReader([]byte(invalidBucketNotificationBuf)), s.accessKey, s.secretKey)
+ c.Assert(err, IsNil)
+
+ client = http.Client{}
+ // execute the HTTP request.
+ response, err = client.Do(request)
+ c.Assert(err, IsNil)
+
+ verifyError(c, response, "InvalidArgument", "Size of filter rule value cannot exceed 1024 bytes in UTF-8 representation", http.StatusBadRequest)
+
invalidBucketNotificationBuf = `s3:ObjectCreated:Putprefiximages/1arn:minio:sns:us-west-1:444455556666:listen`
request, err = newTestSignedRequest("PUT", getPutNotificationURL(s.endPoint, bucketName),
int64(len(invalidBucketNotificationBuf)), bytes.NewReader([]byte(invalidBucketNotificationBuf)), s.accessKey, s.secretKey)