diff --git a/cmd/bucket-notification-handlers.go b/cmd/bucket-notification-handlers.go index d86d29ca3..bfe706639 100644 --- a/cmd/bucket-notification-handlers.go +++ b/cmd/bucket-notification-handlers.go @@ -84,7 +84,6 @@ func (api objectAPIHandlers) GetBucketNotificationHandler(w http.ResponseWriter, writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) return } - config.XMLNS = "http://s3.amazonaws.com/doc/2006-03-01/" config.SetRegion(globalServerRegion) notificationBytes, err := xml.Marshal(config) if err != nil { @@ -127,11 +126,6 @@ func (api objectAPIHandlers) GetBucketNotificationHandler(w http.ResponseWriter, } } - // If xml namespace is empty, set a default value before returning. - if config.XMLNS == "" { - config.XMLNS = "http://s3.amazonaws.com/doc/2006-03-01/" - } - notificationBytes, err := xml.Marshal(config) if err != nil { writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) diff --git a/pkg/bucket/object/lock/lock.go b/pkg/bucket/object/lock/lock.go index ec19c0321..626f4356d 100644 --- a/pkg/bucket/object/lock/lock.go +++ b/pkg/bucket/object/lock/lock.go @@ -233,8 +233,7 @@ func (dr *DefaultRetention) UnmarshalXML(d *xml.Decoder, start xml.StartElement) // Config - object lock configuration specified in // https://docs.aws.amazon.com/AmazonS3/latest/API/Type_API_ObjectLockConfiguration.html type Config struct { - XMLNS string `xml:"xmlns,attr,omitempty"` - XMLName xml.Name `xml:"ObjectLockConfiguration"` + XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ObjectLockConfiguration"` ObjectLockEnabled string `xml:"ObjectLockEnabled"` Rule *struct { DefaultRetention DefaultRetention `xml:"DefaultRetention"` @@ -336,8 +335,7 @@ func (rDate *RetentionDate) MarshalXML(e *xml.Encoder, startElement xml.StartEle // ObjectRetention specified in // https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectRetention.html type ObjectRetention struct { - XMLNS string `xml:"xmlns,attr,omitempty"` - XMLName xml.Name `xml:"Retention"` + XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ Retention"` Mode Mode `xml:"Mode,omitempty"` RetainUntilDate RetentionDate `xml:"RetainUntilDate,omitempty"` } @@ -470,8 +468,7 @@ func ParseObjectLockLegalHoldHeaders(h http.Header) (lhold ObjectLegalHold, err // ObjectLegalHold specified in // https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectLegalHold.html type ObjectLegalHold struct { - XMLNS string `xml:"xmlns,attr,omitempty"` - XMLName xml.Name `xml:"LegalHold"` + XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ LegalHold"` Status LegalHoldStatus `xml:"Status,omitempty"` } diff --git a/pkg/bucket/object/lock/lock_test.go b/pkg/bucket/object/lock/lock_test.go index cd30abbd7..9219b4a1b 100644 --- a/pkg/bucket/object/lock/lock_test.go +++ b/pkg/bucket/object/lock/lock_test.go @@ -154,17 +154,17 @@ func TestParseObjectLockConfig(t *testing.T) { expectErr bool }{ { - value: "yes", + value: "yes", expectedErr: fmt.Errorf("only 'Enabled' value is allowd to ObjectLockEnabled element"), expectErr: true, }, { - value: "EnabledCOMPLIANCE0", + value: "EnabledCOMPLIANCE0", expectedErr: fmt.Errorf("Default retention period must be a positive integer value for 'Days'"), expectErr: true, }, { - value: "EnabledCOMPLIANCE30", + value: "EnabledCOMPLIANCE30", expectedErr: nil, expectErr: false, }, diff --git a/pkg/event/config.go b/pkg/event/config.go index 7a31fdc47..8bf7f8c71 100644 --- a/pkg/event/config.go +++ b/pkg/event/config.go @@ -209,8 +209,7 @@ type topic struct { // Config - notification configuration described in // http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html type Config struct { - XMLNS string `xml:"xmlns,attr,omitempty"` - XMLName xml.Name `xml:"NotificationConfiguration"` + XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ NotificationConfiguration"` QueueList []Queue `xml:"QueueConfiguration,omitempty"` LambdaList []lambda `xml:"CloudFunctionConfiguration,omitempty"` TopicList []topic `xml:"TopicConfiguration,omitempty"` @@ -292,10 +291,5 @@ func ParseConfig(reader io.Reader, region string, targetList *TargetList) (*Conf config.SetRegion(region) - // If xml namespace is empty, set a default value before returning. - if config.XMLNS == "" { - config.XMLNS = "http://s3.amazonaws.com/doc/2006-03-01/" - } - return &config, nil } diff --git a/pkg/event/config_test.go b/pkg/event/config_test.go index 4b5b73224..aea40b6ff 100644 --- a/pkg/event/config_test.go +++ b/pkg/event/config_test.go @@ -398,7 +398,7 @@ func TestQueueToRulesMap(t *testing.T) { func TestConfigUnmarshalXML(t *testing.T) { dataCase1 := []byte(` - + 1 @@ -411,88 +411,88 @@ func TestConfigUnmarshalXML(t *testing.T) { `) dataCase2 := []byte(` - - - 1 - - - - prefix - images/ - - - suffix - jpg - - - - arn:minio:sqs:us-east-1:1:webhook - s3:ObjectCreated:Put - - -`) + + + 1 + + + + prefix + images/ + + + suffix + jpg + + + + arn:minio:sqs:us-east-1:1:webhook + s3:ObjectCreated:Put + + + `) dataCase3 := []byte(` - - - 1 - - arn:minio:sqs:us-east-1:1:webhook - s3:ObjectAccessed:* - s3:ObjectCreated:* - s3:ObjectRemoved:* - - - 2 - - - - prefix - images/ - - - suffix - jpg - - - - arn:minio:sqs:us-east-1:1:webhook - s3:ObjectCreated:Put - - -`) + + + 1 + + arn:minio:sqs:us-east-1:1:webhook + s3:ObjectAccessed:* + s3:ObjectCreated:* + s3:ObjectRemoved:* + + + 2 + + + + prefix + images/ + + + suffix + jpg + + + + arn:minio:sqs:us-east-1:1:webhook + s3:ObjectCreated:Put + + + `) dataCase4 := []byte(` - - - 1 - - arn:minio:sqs:us-east-1:1:webhook - s3:ObjectAccessed:* - s3:ObjectCreated:* - s3:ObjectRemoved:* - - - 1 - - - - suffix - .jpg - - - - arn:aws:lambda:us-west-2:444455556666:cloud-function-A - s3:ObjectCreated:Put - - - arn:aws:sns:us-west-2:444455556666:sns-notification-one - s3:ObjectCreated:* - - -`) - - dataCase5 := []byte(``) + + + 1 + + arn:minio:sqs:us-east-1:1:webhook + s3:ObjectAccessed:* + s3:ObjectCreated:* + s3:ObjectRemoved:* + + + 1 + + + + suffix + .jpg + + + + arn:aws:lambda:us-west-2:444455556666:cloud-function-A + s3:ObjectCreated:Put + + + arn:aws:sns:us-west-2:444455556666:sns-notification-one + s3:ObjectCreated:* + + + `) + + dataCase5 := []byte(``) testCases := []struct { data []byte @@ -518,7 +518,7 @@ func TestConfigUnmarshalXML(t *testing.T) { func TestConfigValidate(t *testing.T) { data := []byte(` - + 1 @@ -535,7 +535,7 @@ func TestConfigValidate(t *testing.T) { } data = []byte(` - + 1 @@ -561,7 +561,7 @@ func TestConfigValidate(t *testing.T) { } data = []byte(` - + 1 @@ -625,7 +625,7 @@ func TestConfigValidate(t *testing.T) { func TestConfigSetRegion(t *testing.T) { data := []byte(` - + 1 @@ -642,7 +642,7 @@ func TestConfigSetRegion(t *testing.T) { } data = []byte(` - + 1 @@ -668,7 +668,7 @@ func TestConfigSetRegion(t *testing.T) { } data = []byte(` - + 1 @@ -729,7 +729,7 @@ func TestConfigSetRegion(t *testing.T) { func TestConfigToRulesMap(t *testing.T) { data := []byte(` - + 1 @@ -746,7 +746,7 @@ func TestConfigToRulesMap(t *testing.T) { } data = []byte(` - + 1 @@ -772,7 +772,7 @@ func TestConfigToRulesMap(t *testing.T) { } data = []byte(` - + 1 @@ -832,7 +832,7 @@ func TestConfigToRulesMap(t *testing.T) { func TestParseConfig(t *testing.T) { reader1 := strings.NewReader(` - + 1 @@ -845,7 +845,7 @@ func TestParseConfig(t *testing.T) { `) reader2 := strings.NewReader(` - + 1 @@ -867,7 +867,7 @@ func TestParseConfig(t *testing.T) { `) reader3 := strings.NewReader(` - + 1 @@ -897,7 +897,7 @@ func TestParseConfig(t *testing.T) { `) reader4 := strings.NewReader(` - + 1