Skip to content

Commit

Permalink
Added test for id length exceeding 255 chars
Browse files Browse the repository at this point in the history
Signed-off-by: Aayush Chouhan <[email protected]>
  • Loading branch information
achouhan09 committed Jan 3, 2025
1 parent 0fd422f commit 0e4c052
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/test/lifecycle/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,25 @@ function id_lifecycle_configuration(Bucket, Key) {
};
}

function id_length_lifecycle_configuration(Bucket, Key) {
const ID = 'A'.repeat(260); // ID contains more then 255 characters
return {
Bucket,
LifecycleConfiguration: {
Rules: [{
ID,
Expiration: {
Days: 17,
},
Filter: {
Prefix: Key,
},
Status: 'Enabled',
}, ],
},
};
}

async function put_get_lifecycle_configuration(Bucket, putLifecycleParams, s3) {
const putLifecycleResult = await s3.putBucketLifecycleConfiguration(putLifecycleParams);
console.log('put lifecycle params:', putLifecycleParams, 'result', putLifecycleResult);
Expand Down Expand Up @@ -512,3 +531,13 @@ exports.test_and_prefix_size = async function(Bucket, Key, s3) {
assert(actualFilter.ObjectSizeGreaterThan === expectedFilter.ObjectSizeGreaterThan, 'and prefix size filter - ObjectSizeGreaterThan');
assert(actualFilter.ObjectSizeLessThan === expectedFilter.ObjectSizeLessThan, 'and prefix size filter - ObjectSizeLessThan');
};

exports.test_rule_id_length = async function(Bucket, Key, s3) {
const putLifecycleParams = id_length_lifecycle_configuration(Bucket, Key);

await s3.putBucketLifecycleConfiguration(putLifecycleParams)
.catch(error => {
assert(error.code === 'InvalidArgument', 'Expected InvalidArgument: id length exceeding 255 characters');
console.log('Expected error received, id length exceeding 255 characters');
});
};
1 change: 1 addition & 0 deletions src/test/system_tests/test_lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ async function main() {
await commonTests.test_rule_id(Bucket, Key, s3);
await commonTests.test_filter_size(Bucket, s3);
await commonTests.test_and_prefix_size(Bucket, Key, s3);
await commonTests.test_rule_id_length(Bucket, Key, s3);

const getObjectParams = {
Bucket,
Expand Down

0 comments on commit 0e4c052

Please sign in to comment.