@@ -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,8 @@ 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
+ console . log ( "Received error: " , error ) ;
639
+ assert ( error . Code === 'InvalidArgument' , 'Expected InvalidArgument: duplicate ID found in the rules' ) ;
637
640
}
638
641
} ;
639
642
@@ -647,6 +650,80 @@ exports.test_rule_status_value = async function(Bucket, Key, s3) {
647
650
await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
648
651
assert . fail ( 'Expected MalformedXML error due to wrong status value, but received a different response' ) ;
649
652
} catch ( error ) {
650
- assert ( error . code === 'MalformedXML' , `Expected MalformedXML error: due to invalid status value` ) ;
653
+ assert ( error . Code === 'MalformedXML' , `Expected MalformedXML error: due to invalid status value` ) ;
654
+ }
655
+ } ;
656
+
657
+ exports . test_invalid_filter_format = async function ( Bucket , Key , s3 ) {
658
+ const putLifecycleParams = tags_lifecycle_configuration ( Bucket , Key ) ;
659
+
660
+ // append prefix for invalid filter: "And" condition is missing, but multiple filters are present
661
+ putLifecycleParams . LifecycleConfiguration . Rules [ 0 ] . Filter . Prefix = 'test-prefix' ;
662
+
663
+ try {
664
+ await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
665
+ assert . fail ( 'Expected MalformedXML error due to missing "And" condition for multiple filters' ) ;
666
+ } catch ( error ) {
667
+ assert ( error . Code === 'MalformedXML' , 'Expected MalformedXML error: due to missing "And" condition' ) ;
668
+ }
669
+ } ;
670
+
671
+ exports . test_invalid_expiration_date_format = async function ( Bucket , Key , s3 ) {
672
+ const putLifecycleParams = date_lifecycle_configuration ( Bucket , Key ) ;
673
+
674
+ // set expiration with a Date that is not at midnight UTC (incorrect time specified)
675
+ putLifecycleParams . LifecycleConfiguration . Rules [ 0 ] . Expiration . Date = new Date ( '2025-01-01T15:30:00Z' ) ;
676
+
677
+ try {
678
+ await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
679
+ assert . fail ( 'Expected error due to incorrect date format (not at midnight UTC), but request was successful' ) ;
680
+ } catch ( error ) {
681
+ assert ( error . Code === 'InvalidArgument' , 'Expected InvalidArgument error: date must be at midnight UTC' ) ;
682
+ }
683
+ } ;
684
+
685
+ exports . test_expiration_multiple_fields = async function ( Bucket , Key , s3 ) {
686
+ const putLifecycleParams = days_lifecycle_configuration ( Bucket , Key ) ;
687
+
688
+ // append ExpiredObjectDeleteMarker for invalid expiration with multiple fields
689
+ putLifecycleParams . LifecycleConfiguration . Rules [ 0 ] . Expiration . ExpiredObjectDeleteMarker = false ;
690
+
691
+ try {
692
+ await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
693
+ assert . fail ( 'Expected MalformedXML error due to multiple expiration fields' ) ;
694
+ } catch ( error ) {
695
+ assert ( error . Code === 'MalformedXML' , 'Expected MalformedXML error: due to multiple expiration fields' ) ;
696
+ }
697
+ } ;
698
+
699
+ exports . test_abortincompletemultipartupload_with_tags = async function ( Bucket , Key , s3 ) {
700
+ const putLifecycleParams = tags_lifecycle_configuration ( Bucket ) ;
701
+
702
+ // invalid combination of AbortIncompleteMultipartUpload with tags
703
+ putLifecycleParams . LifecycleConfiguration . Rules [ 0 ] . AbortIncompleteMultipartUpload = {
704
+ DaysAfterInitiation : 5
705
+ } ;
706
+
707
+ try {
708
+ await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
709
+ assert . fail ( 'Expected InvalidArgument error due to AbortIncompleteMultipartUpload specified with tags' ) ;
710
+ } catch ( error ) {
711
+ assert ( error . Code === 'InvalidArgument' , 'Expected InvalidArgument: AbortIncompleteMultipartUpload cannot be specified with tags' ) ;
712
+ }
713
+ } ;
714
+
715
+ exports . test_abortincompletemultipartupload_with_sizes = async function ( Bucket , Key , s3 ) {
716
+ const putLifecycleParams = filter_size_lifecycle_configuration ( Bucket ) ;
717
+
718
+ // invalid combination of AbortIncompleteMultipartUpload with object size filters
719
+ putLifecycleParams . LifecycleConfiguration . Rules [ 0 ] . AbortIncompleteMultipartUpload = {
720
+ DaysAfterInitiation : 5
721
+ } ;
722
+
723
+ try {
724
+ await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
725
+ assert . fail ( 'Expected InvalidArgument error due to AbortIncompleteMultipartUpload specified with object size' ) ;
726
+ } catch ( error ) {
727
+ assert ( error . Code === 'InvalidArgument' , 'Expected InvalidArgument: AbortIncompleteMultipartUpload cannot be specified with object size' ) ;
651
728
}
652
729
} ;
0 commit comments