@@ -162,8 +162,10 @@ function size_gt_lt_lifecycle_configuration(Bucket, gt, lt) {
162
162
Date : midnight ,
163
163
} ,
164
164
Filter : {
165
- ObjectSizeLessThan : lt ,
166
- ObjectSizeGreaterThan : gt
165
+ And : {
166
+ ObjectSizeLessThan : lt ,
167
+ ObjectSizeGreaterThan : gt ,
168
+ } ,
167
169
} ,
168
170
Status : 'Enabled' ,
169
171
} , ] ,
@@ -368,7 +370,7 @@ function duplicate_id_lifecycle_configuration(Bucket, Key) {
368
370
Bucket,
369
371
LifecycleConfiguration : {
370
372
Rules : [ {
371
- ID1 ,
373
+ ID : ID1 ,
372
374
Expiration : {
373
375
Days : 17 ,
374
376
} ,
@@ -378,7 +380,7 @@ function duplicate_id_lifecycle_configuration(Bucket, Key) {
378
380
Status : 'Enabled' ,
379
381
} ,
380
382
{
381
- ID2 ,
383
+ ID : ID2 ,
382
384
Expiration : {
383
385
Days : 18 ,
384
386
} ,
@@ -622,7 +624,7 @@ exports.test_rule_id_length = async function(Bucket, Key, s3) {
622
624
await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
623
625
assert . fail ( `Expected error for ID length exceeding maximum allowed characters ${ s3_const . MAX_RULE_ID_LENGTH } , but request was successful` ) ;
624
626
} catch ( error ) {
625
- assert ( error . code === 'InvalidArgument' , `Expected InvalidArgument: id length exceeding ${ s3_const . MAX_RULE_ID_LENGTH } characters` ) ;
627
+ assert ( error . Code === 'InvalidArgument' , `Expected InvalidArgument: id length exceeding ${ s3_const . MAX_RULE_ID_LENGTH } characters` ) ;
626
628
}
627
629
} ;
628
630
@@ -633,7 +635,7 @@ exports.test_rule_duplicate_id = async function(Bucket, Key, s3) {
633
635
await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
634
636
assert . fail ( 'Expected error for duplicate rule ID, but request was successful' ) ;
635
637
} catch ( error ) {
636
- assert ( error . code === 'InvalidArgument' , 'Expected InvalidArgument: duplicate ID found in the rules' ) ;
638
+ assert ( error . Code === 'InvalidArgument' , 'Expected InvalidArgument: duplicate ID found in the rules' ) ;
637
639
}
638
640
} ;
639
641
@@ -647,6 +649,80 @@ exports.test_rule_status_value = async function(Bucket, Key, s3) {
647
649
await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
648
650
assert . fail ( 'Expected MalformedXML error due to wrong status value, but received a different response' ) ;
649
651
} catch ( error ) {
650
- assert ( error . code === 'MalformedXML' , `Expected MalformedXML error: due to invalid status value` ) ;
652
+ assert ( error . Code === 'MalformedXML' , `Expected MalformedXML error: due to invalid status value` ) ;
653
+ }
654
+ } ;
655
+
656
+ exports . test_invalid_filter_format = async function ( Bucket , Key , s3 ) {
657
+ const putLifecycleParams = tags_lifecycle_configuration ( Bucket , Key ) ;
658
+
659
+ // append prefix for invalid filter: "And" condition is missing, but multiple filters are present
660
+ putLifecycleParams . LifecycleConfiguration . Rules [ 0 ] . Filter . Prefix = 'test-prefix' ;
661
+
662
+ try {
663
+ await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
664
+ assert . fail ( 'Expected MalformedXML error due to missing "And" condition for multiple filters' ) ;
665
+ } catch ( error ) {
666
+ assert ( error . Code === 'MalformedXML' , 'Expected MalformedXML error: due to missing "And" condition' ) ;
667
+ }
668
+ } ;
669
+
670
+ exports . test_invalid_expiration_date_format = async function ( Bucket , Key , s3 ) {
671
+ const putLifecycleParams = date_lifecycle_configuration ( Bucket , Key ) ;
672
+
673
+ // set expiration with a Date that is not at midnight UTC (incorrect time specified)
674
+ putLifecycleParams . LifecycleConfiguration . Rules [ 0 ] . Expiration . Date = new Date ( '2025-01-01T15:30:00Z' ) ;
675
+
676
+ try {
677
+ await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
678
+ assert . fail ( 'Expected error due to incorrect date format (not at midnight UTC), but request was successful' ) ;
679
+ } catch ( error ) {
680
+ assert ( error . Code === 'InvalidArgument' , 'Expected InvalidArgument error: date must be at midnight UTC' ) ;
681
+ }
682
+ } ;
683
+
684
+ exports . test_expiration_multiple_fields = async function ( Bucket , Key , s3 ) {
685
+ const putLifecycleParams = days_lifecycle_configuration ( Bucket , Key ) ;
686
+
687
+ // append ExpiredObjectDeleteMarker for invalid expiration with multiple fields
688
+ putLifecycleParams . LifecycleConfiguration . Rules [ 0 ] . Expiration . ExpiredObjectDeleteMarker = false ;
689
+
690
+ try {
691
+ await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
692
+ assert . fail ( 'Expected MalformedXML error due to multiple expiration fields' ) ;
693
+ } catch ( error ) {
694
+ assert ( error . Code === 'MalformedXML' , 'Expected MalformedXML error: due to multiple expiration fields' ) ;
695
+ }
696
+ } ;
697
+
698
+ exports . test_abortincompletemultipartupload_with_tags = async function ( Bucket , Key , s3 ) {
699
+ const putLifecycleParams = tags_lifecycle_configuration ( Bucket ) ;
700
+
701
+ // invalid combination of AbortIncompleteMultipartUpload with tags
702
+ putLifecycleParams . LifecycleConfiguration . Rules [ 0 ] . AbortIncompleteMultipartUpload = {
703
+ DaysAfterInitiation : 5
704
+ } ;
705
+
706
+ try {
707
+ await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
708
+ assert . fail ( 'Expected InvalidArgument error due to AbortIncompleteMultipartUpload specified with tags' ) ;
709
+ } catch ( error ) {
710
+ assert ( error . Code === 'InvalidArgument' , 'Expected InvalidArgument: AbortIncompleteMultipartUpload cannot be specified with tags' ) ;
711
+ }
712
+ } ;
713
+
714
+ exports . test_abortincompletemultipartupload_with_sizes = async function ( Bucket , Key , s3 ) {
715
+ const putLifecycleParams = filter_size_lifecycle_configuration ( Bucket ) ;
716
+
717
+ // invalid combination of AbortIncompleteMultipartUpload with object size filters
718
+ putLifecycleParams . LifecycleConfiguration . Rules [ 0 ] . AbortIncompleteMultipartUpload = {
719
+ DaysAfterInitiation : 5
720
+ } ;
721
+
722
+ try {
723
+ await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
724
+ assert . fail ( 'Expected InvalidArgument error due to AbortIncompleteMultipartUpload specified with object size' ) ;
725
+ } catch ( error ) {
726
+ assert ( error . Code === 'InvalidArgument' , 'Expected InvalidArgument: AbortIncompleteMultipartUpload cannot be specified with object size' ) ;
651
727
}
652
728
} ;
0 commit comments