@@ -161,8 +161,10 @@ function size_gt_lt_lifecycle_configuration(Bucket, gt, lt) {
161
161
Date : midnight ,
162
162
} ,
163
163
Filter : {
164
- ObjectSizeLessThan : lt ,
165
- ObjectSizeGreaterThan : gt
164
+ And : {
165
+ ObjectSizeLessThan : lt ,
166
+ ObjectSizeGreaterThan : gt ,
167
+ } ,
166
168
} ,
167
169
Status : 'Enabled' ,
168
170
} , ] ,
@@ -366,7 +368,7 @@ function duplicate_id_lifecycle_configuration(Bucket, Key) {
366
368
Bucket,
367
369
LifecycleConfiguration : {
368
370
Rules : [ {
369
- ID1 ,
371
+ ID : ID1 ,
370
372
Expiration : {
371
373
Days : 17 ,
372
374
} ,
@@ -376,7 +378,7 @@ function duplicate_id_lifecycle_configuration(Bucket, Key) {
376
378
Status : 'Enabled' ,
377
379
} ,
378
380
{
379
- ID2 ,
381
+ ID : ID2 ,
380
382
Expiration : {
381
383
Days : 18 ,
382
384
} ,
@@ -555,7 +557,7 @@ exports.test_rule_id_length = async function(Bucket, Key, s3) {
555
557
await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
556
558
assert . fail ( `Expected error for ID length exceeding maximum allowed characters ${ s3_const . MAX_RULE_ID_LENGTH } , but request was successful` ) ;
557
559
} catch ( error ) {
558
- assert ( error . code === 'InvalidArgument' , `Expected InvalidArgument: id length exceeding ${ s3_const . MAX_RULE_ID_LENGTH } characters` ) ;
560
+ assert ( error . Code === 'InvalidArgument' , `Expected InvalidArgument: id length exceeding ${ s3_const . MAX_RULE_ID_LENGTH } characters` ) ;
559
561
}
560
562
} ;
561
563
@@ -566,7 +568,7 @@ exports.test_rule_duplicate_id = async function(Bucket, Key, s3) {
566
568
await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
567
569
assert . fail ( 'Expected error for duplicate rule ID, but request was successful' ) ;
568
570
} catch ( error ) {
569
- assert ( error . code === 'InvalidArgument' , 'Expected InvalidArgument: duplicate ID found in the rules' ) ;
571
+ assert ( error . Code === 'InvalidArgument' , 'Expected InvalidArgument: duplicate ID found in the rules' ) ;
570
572
}
571
573
} ;
572
574
@@ -580,6 +582,80 @@ exports.test_rule_status_value = async function(Bucket, Key, s3) {
580
582
await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
581
583
assert . fail ( 'Expected MalformedXML error due to wrong status value, but received a different response' ) ;
582
584
} catch ( error ) {
583
- assert ( error . code === 'MalformedXML' , `Expected MalformedXML error: due to invalid status value` ) ;
585
+ assert ( error . Code === 'MalformedXML' , `Expected MalformedXML error: due to invalid status value` ) ;
586
+ }
587
+ } ;
588
+
589
+ exports . test_invalid_filter_format = async function ( Bucket , Key , s3 ) {
590
+ const putLifecycleParams = tags_lifecycle_configuration ( Bucket , Key ) ;
591
+
592
+ // append prefix for invalid filter: "And" condition is missing, but multiple filters are present
593
+ putLifecycleParams . LifecycleConfiguration . Rules [ 0 ] . Filter . Prefix = 'test-prefix' ;
594
+
595
+ try {
596
+ await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
597
+ assert . fail ( 'Expected MalformedXML error due to missing "And" condition for multiple filters' ) ;
598
+ } catch ( error ) {
599
+ assert ( error . Code === 'MalformedXML' , 'Expected MalformedXML error: due to missing "And" condition' ) ;
600
+ }
601
+ } ;
602
+
603
+ exports . test_invalid_expiration_date_format = async function ( Bucket , Key , s3 ) {
604
+ const putLifecycleParams = date_lifecycle_configuration ( Bucket , Key ) ;
605
+
606
+ // set expiration with a Date that is not at midnight UTC (incorrect time specified)
607
+ putLifecycleParams . LifecycleConfiguration . Rules [ 0 ] . Expiration . Date = new Date ( '2025-01-01T15:30:00Z' ) ;
608
+
609
+ try {
610
+ await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
611
+ assert . fail ( 'Expected error due to incorrect date format (not at midnight UTC), but request was successful' ) ;
612
+ } catch ( error ) {
613
+ assert ( error . Code === 'InvalidArgument' , 'Expected InvalidArgument error: date must be at midnight UTC' ) ;
614
+ }
615
+ } ;
616
+
617
+ exports . test_expiration_multiple_fields = async function ( Bucket , Key , s3 ) {
618
+ const putLifecycleParams = days_lifecycle_configuration ( Bucket , Key ) ;
619
+
620
+ // append ExpiredObjectDeleteMarker for invalid expiration with multiple fields
621
+ putLifecycleParams . LifecycleConfiguration . Rules [ 0 ] . Expiration . ExpiredObjectDeleteMarker = false ;
622
+
623
+ try {
624
+ await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
625
+ assert . fail ( 'Expected MalformedXML error due to multiple expiration fields' ) ;
626
+ } catch ( error ) {
627
+ assert ( error . Code === 'MalformedXML' , 'Expected MalformedXML error: due to multiple expiration fields' ) ;
628
+ }
629
+ } ;
630
+
631
+ exports . test_abortincompletemultipartupload_with_tags = async function ( Bucket , Key , s3 ) {
632
+ const putLifecycleParams = tags_lifecycle_configuration ( Bucket ) ;
633
+
634
+ // invalid combination of AbortIncompleteMultipartUpload with tags
635
+ putLifecycleParams . LifecycleConfiguration . Rules [ 0 ] . AbortIncompleteMultipartUpload = {
636
+ DaysAfterInitiation : 5
637
+ } ;
638
+
639
+ try {
640
+ await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
641
+ assert . fail ( 'Expected InvalidArgument error due to AbortIncompleteMultipartUpload specified with tags' ) ;
642
+ } catch ( error ) {
643
+ assert ( error . Code === 'InvalidArgument' , 'Expected InvalidArgument: AbortIncompleteMultipartUpload cannot be specified with tags' ) ;
644
+ }
645
+ } ;
646
+
647
+ exports . test_abortincompletemultipartupload_with_sizes = async function ( Bucket , Key , s3 ) {
648
+ const putLifecycleParams = filter_size_lifecycle_configuration ( Bucket ) ;
649
+
650
+ // invalid combination of AbortIncompleteMultipartUpload with object size filters
651
+ putLifecycleParams . LifecycleConfiguration . Rules [ 0 ] . AbortIncompleteMultipartUpload = {
652
+ DaysAfterInitiation : 5
653
+ } ;
654
+
655
+ try {
656
+ await s3 . putBucketLifecycleConfiguration ( putLifecycleParams ) ;
657
+ assert . fail ( 'Expected InvalidArgument error due to AbortIncompleteMultipartUpload specified with object size' ) ;
658
+ } catch ( error ) {
659
+ assert ( error . Code === 'InvalidArgument' , 'Expected InvalidArgument: AbortIncompleteMultipartUpload cannot be specified with object size' ) ;
584
660
}
585
661
} ;
0 commit comments