@@ -206,6 +206,66 @@ describe('createAndStoreObject', () => {
206206 done ( ) ;
207207 } ) ;
208208 } ) ;
209+
210+ it ( 'should trigger oplog event for archived object in version-suspended bucket' , done => {
211+ const archivedObjMD = {
212+ 'content-md5' : 'abc123' ,
213+ 'content-length' : 100 ,
214+ archive : {
215+ archiveInfo : { archiveID : 'archive-123' } ,
216+ } ,
217+ } ;
218+
219+ sinon . stub ( testBucket , 'isVersioningEnabled' ) . returns ( false ) ;
220+ sinon . spy ( metadata , 'putObjectMD' ) ;
221+
222+ const request = new DummyRequest ( {
223+ bucketName,
224+ namespace : 'default' ,
225+ objectKey,
226+ headers : { } ,
227+ url : `/${ bucketName } /${ objectKey } ` ,
228+ } , Buffer . from ( 'new data' , 'utf8' ) ) ;
229+
230+ createAndStoreObject ( bucketName , testBucket , objectKey , archivedObjMD ,
231+ authInfo , canonicalID , null , request , false , null ,
232+ [ 'overhead' ] , log , 's3:ObjectCreated:Put' , err => {
233+ assert . ifError ( err ) ;
234+ const options = getStoredOptions ( ) ;
235+ assert . strictEqual ( options . needOplogUpdate , true ) ;
236+ assert . strictEqual ( options . originOp , 's3:ReplaceArchivedObject' ) ;
237+ done ( ) ;
238+ } ) ;
239+ } ) ;
240+
241+ it ( 'should not trigger oplog event when archiveInfo is absent' , done => {
242+ const archivedObjMD = {
243+ 'content-md5' : 'abc123' ,
244+ 'content-length' : 100 ,
245+ archive : {
246+ restoreRequestedAt : new Date ( ) . toISOString ( ) ,
247+ } ,
248+ } ;
249+ sinon . spy ( metadata , 'putObjectMD' ) ;
250+
251+ const request = new DummyRequest ( {
252+ bucketName,
253+ namespace : 'default' ,
254+ objectKey,
255+ headers : { } ,
256+ url : `/${ bucketName } /${ objectKey } ` ,
257+ } , Buffer . from ( 'new data' , 'utf8' ) ) ;
258+
259+ createAndStoreObject ( bucketName , testBucket , objectKey , archivedObjMD ,
260+ authInfo , canonicalID , null , request , false , null ,
261+ [ 'overhead' ] , log , 's3:ObjectCreated:Put' , err => {
262+ assert . ifError ( err ) ;
263+ const options = getStoredOptions ( ) ;
264+ assert . strictEqual ( options . needOplogUpdate , undefined ) ;
265+ assert . strictEqual ( options . originOp , undefined ) ;
266+ done ( ) ;
267+ } ) ;
268+ } ) ;
209269 } ) ;
210270
211271 describe ( 'Cold storage restoration (putObjectVersion)' , ( ) => {
0 commit comments