From 830ba208ffbba55c9c0e8f0d420425e7189e248a Mon Sep 17 00:00:00 2001 From: Dimitrios Vasilas Date: Fri, 27 Dec 2024 17:41:53 +0200 Subject: [PATCH] CLDSRV-552: Set originOp for put obj retention & legal hold --- lib/api/objectPutLegalHold.js | 2 ++ lib/api/objectPutRetention.js | 1 + tests/unit/api/objectPutLegalHold.js | 12 ++++++++++++ tests/unit/api/objectPutRetention.js | 12 ++++++++++++ 4 files changed, 27 insertions(+) diff --git a/lib/api/objectPutLegalHold.js b/lib/api/objectPutLegalHold.js index e5ba15b44b..b1d98cb706 100644 --- a/lib/api/objectPutLegalHold.js +++ b/lib/api/objectPutLegalHold.js @@ -94,6 +94,8 @@ function objectPutLegalHold(authInfo, request, log, callback) { objectMD.replicationInfo = Object.assign({}, objectMD.replicationInfo, replicationInfo); } + // eslint-disable-next-line no-param-reassign + objectMD.originOp = 's3:ObjectLegalHold:Put'; metadata.putObjectMD(bucket.getName(), objectKey, objectMD, params, log, err => next(err, bucket, objectMD)); }, diff --git a/lib/api/objectPutRetention.js b/lib/api/objectPutRetention.js index 9bbf9fca14..8dab844e69 100644 --- a/lib/api/objectPutRetention.js +++ b/lib/api/objectPutRetention.js @@ -131,6 +131,7 @@ function objectPutRetention(authInfo, request, log, callback) { objectMD.replicationInfo = Object.assign({}, objectMD.replicationInfo, replicationInfo); } + objectMD.originOp = 's3:ObjectRetention:Put'; /* eslint-enable no-param-reassign */ metadata.putObjectMD(bucket.getName(), objectKey, objectMD, params, log, err => next(err, bucket, objectMD)); diff --git a/tests/unit/api/objectPutLegalHold.js b/tests/unit/api/objectPutLegalHold.js index 839d7d7edf..86c41efe89 100644 --- a/tests/unit/api/objectPutLegalHold.js +++ b/tests/unit/api/objectPutLegalHold.js @@ -98,5 +98,17 @@ describe('putObjectLegalHold API', () => { }); }); }); + + it('should set originOp in object\'s metadata to s3:ObjectLegalHold:Put', done => { + objectPutLegalHold(authInfo, putLegalHoldReq('ON'), log, err => { + assert.ifError(err); + return metadata.getObjectMD(bucketName, objectName, {}, log, + (err, objMD) => { + assert.ifError(err); + assert.strictEqual(objMD.originOp, 's3:ObjectLegalHold:Put'); + return done(); + }); + }); + }); }); }); diff --git a/tests/unit/api/objectPutRetention.js b/tests/unit/api/objectPutRetention.js index 9a24d7a340..89d5084fe9 100644 --- a/tests/unit/api/objectPutRetention.js +++ b/tests/unit/api/objectPutRetention.js @@ -160,6 +160,18 @@ describe('putObjectRetention API', () => { }); }); + it('should set originOp in object\'s metadata to s3:ObjectRetention:Put', done => { + objectPutRetention(authInfo, putObjRetRequestGovernance, log, err => { + assert.ifError(err); + return metadata.getObjectMD(bucketName, objectName, {}, log, + (err, objMD) => { + assert.ifError(err); + assert.strictEqual(objMD.originOp, 's3:ObjectRetention:Put'); + return done(); + }); + }); + }); + it('should disallow COMPLIANCE => GOVERNANCE', done => { objectPutRetention(authInfo, putObjRetRequestCompliance, log, err => { assert.ifError(err);