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 793965511e..6510f5a579 100644 --- a/lib/api/objectPutRetention.js +++ b/lib/api/objectPutRetention.js @@ -118,6 +118,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 ec14530ef5..4bf24cbcea 100644 --- a/tests/unit/api/objectPutRetention.js +++ b/tests/unit/api/objectPutRetention.js @@ -159,6 +159,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);