Skip to content

Commit

Permalink
modify lifecycle rule to have prefix instead of filter
Browse files Browse the repository at this point in the history
Signed-off-by: nadav mizrahi <[email protected]>
  • Loading branch information
nadavMiz committed Apr 19, 2023
1 parent 7b7abb1 commit 4653dac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
17 changes: 10 additions & 7 deletions src/endpoint/s3/ops/s3_put_bucket_lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,19 @@ async function put_bucket_lifecycle(req) {
}
current_rule.status = rule.Status[0];

if (rule.Prefix) {
dbg.error('Rule should not have prefix, it should be filter.prefix', rule);
throw new S3Error(S3Error.InvalidArgument);
if (rule.Prefix && rule.Filter) {
dbg.error('Rule should not have both prefix and filter', rule);
throw new S3Error(S3Error.MalformedXML);
}

if (!(rule.Filter && rule.Filter.length === 1)) {
dbg.error('Rule should have filter', rule);
throw new S3Error(S3Error.InvalidArgument);
if (rule.Prefix && rule.Prefix.length === 1) {
current_rule.filter = { prefix: rule.Prefix[0] };
} else if (rule.Filter && rule.Filter.length === 1) {
current_rule.filter = parse_filter(rule.Filter[0]);
} else {
dbg.error('Rule should have either a prefix or a filter', rule);
throw new S3Error(S3Error.MalformedXML);
}
current_rule.filter = parse_filter(rule.Filter[0]);

// Since other actions are not implemented, Expiration
// is expected here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ s3tests_boto3.functional.test_s3.test_lifecycle_expiration_versioning_enabled
s3tests_boto3.functional.test_s3.test_lifecycle_expiration_tags2
s3tests_boto3.functional.test_s3.test_lifecycle_expiration_versioned_tags2
s3tests_boto3.functional.test_s3.test_lifecycle_expiration_noncur_tags1
s3tests_boto3.functional.test_s3.test_lifecycle_set_date
s3tests_boto3.functional.test_s3.test_lifecycle_expiration_header_put
s3tests_boto3.functional.test_s3.test_lifecycle_expiration_header_head
s3tests_boto3.functional.test_s3.test_lifecycle_expiration_header_tags_head
s3tests_boto3.functional.test_s3.test_lifecycle_transition_set_invalid_date
s3tests_boto3.functional.test_s3.test_put_obj_enc_conflict_c_s3
s3tests_boto3.functional.test_s3.test_put_obj_enc_conflict_c_kms
s3tests_boto3.functional.test_s3.test_put_obj_enc_conflict_s3_kms
s3tests_boto3.functional.test_s3.test_put_obj_enc_conflict_bad_enc_kms
s3tests_boto3.functional.test_s3.test_bucket_policy_put_obj_s3_noenc
s3tests_boto3.functional.test_s3.test_bucket_policy_put_obj_s3_kms
s3tests_boto3.functional.test_s3.test_bucket_policy_put_obj_kms_noenc
Expand Down

0 comments on commit 4653dac

Please sign in to comment.