Skip to content

Commit 3e94f8d

Browse files
add tests for clearing GOVERNANCE retention in test_s3_worm
Covers the empty Retention body flow introduced by this PR: - fail to clear without bypass flag (AccessDenied) - clear GOVERNANCE retention with bypass flag - confirm retention is removed (NoSuchObjectLockConfiguration) - set retention again after clearing Fixes: DFBUGS-8949 Signed-off-by: kajalpareek-lab <pareekkajal97@gmail.com>
1 parent 0e19f36 commit 3e94f8d

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

src/test/integration_tests/api/s3/test_s3_worm.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,68 @@ mocha.describe('s3 worm', function() {
566566
});
567567
});
568568

569+
mocha.describe('clear GOVERNANCE retention with empty Retention', function() {
570+
const CLEAR_RET_KEY = 'clear-retention-test';
571+
let clear_ret_version_id;
572+
573+
mocha.it('should create object with GOVERNANCE retention', async function() {
574+
const shortDate = new Date();
575+
shortDate.setSeconds(shortDate.getSeconds() + 60);
576+
const res = await s3_owner.putObject({
577+
Bucket: BKT1,
578+
Key: CLEAR_RET_KEY,
579+
Body: file_body,
580+
ContentType: 'text/plain',
581+
ObjectLockMode: 'GOVERNANCE',
582+
ObjectLockRetainUntilDate: shortDate
583+
});
584+
clear_ret_version_id = res.VersionId;
585+
assert.ok(res.VersionId);
586+
});
587+
588+
mocha.it('should fail to clear retention without bypass flag', async function() {
589+
await assert_throws_async(s3_owner.putObjectRetention({
590+
Bucket: BKT1,
591+
Key: CLEAR_RET_KEY,
592+
VersionId: clear_ret_version_id,
593+
Retention: {},
594+
}), 'AccessDenied', 'Access Denied');
595+
});
596+
597+
mocha.it('should clear GOVERNANCE retention with bypass flag', async function() {
598+
const res = await s3_owner.putObjectRetention({
599+
Bucket: BKT1,
600+
Key: CLEAR_RET_KEY,
601+
VersionId: clear_ret_version_id,
602+
Retention: {},
603+
BypassGovernanceRetention: true,
604+
});
605+
delete res.$metadata;
606+
assert.deepEqual(res, {});
607+
});
608+
609+
mocha.it('should confirm retention is cleared', async function() {
610+
await assert_throws_async(s3_owner.getObjectRetention({
611+
Bucket: BKT1,
612+
Key: CLEAR_RET_KEY,
613+
VersionId: clear_ret_version_id,
614+
}), 'NoSuchObjectLockConfiguration', 'The specified object does not have a ObjectLock configuration');
615+
});
616+
617+
mocha.it('should be able to set retention again after clearing', async function() {
618+
const newDate = new Date();
619+
newDate.setDate(newDate.getDate() + 1);
620+
const res = await s3_owner.putObjectRetention({
621+
Bucket: BKT1,
622+
Key: CLEAR_RET_KEY,
623+
VersionId: clear_ret_version_id,
624+
Retention: { Mode: 'GOVERNANCE', RetainUntilDate: newDate },
625+
});
626+
delete res.$metadata;
627+
assert.deepEqual(res, {});
628+
});
629+
});
630+
569631
mocha.describe('legal hold toggle (on/off)', function() {
570632
const LEGAL_HOLD_TOGGLE_KEY = 'legal-hold-toggle-test';
571633
let legal_hold_toggle_version_id;

0 commit comments

Comments
 (0)