@@ -195,6 +195,219 @@ mocha.describe('s3_ops', function() {
195
195
// cleanup
196
196
await rpc_client . account . delete_account ( { email : "obc-account@noobaa.io" } ) ;
197
197
} ) ;
198
+
199
+
200
+ mocha . describe ( 'bucket-lifecycle' , function ( ) {
201
+
202
+ mocha . before ( async function ( ) {
203
+ await s3 . createBucket ( { Bucket : "lifecycle-bucket" } ) ;
204
+ } ) ;
205
+
206
+ mocha . it ( 'should put and get bucket lifecycle with Prefix' , async function ( ) {
207
+
208
+ // put bucket lifecycle
209
+ const params = {
210
+ Bucket : "lifecycle-bucket" ,
211
+ LifecycleConfiguration : {
212
+ Rules : [ {
213
+ ID : 'rule1' ,
214
+ Status : 'Enabled' ,
215
+ Prefix : 'prefix1-prefix' ,
216
+ Expiration : {
217
+ Days : 1
218
+ }
219
+ } ]
220
+ }
221
+ } ;
222
+ await s3 . putBucketLifecycleConfiguration ( params ) ;
223
+
224
+ // get` bucket lifecycle
225
+ const res = await s3 . getBucketLifecycleConfiguration ( { Bucket : "lifecycle-bucket" } ) ;
226
+ assert . strictEqual ( res . Rules . length , 1 ) ;
227
+ assert . strictEqual ( res . Rules [ 0 ] . ID , 'rule1' ) ;
228
+ assert . strictEqual ( res . Rules [ 0 ] . Status , 'Enabled' ) ;
229
+ assert . strictEqual ( res . Rules [ 0 ] . Prefix , 'prefix1-prefix' ) ;
230
+ assert . strictEqual ( res . Rules [ 0 ] . Expiration . Days , 1 ) ;
231
+ } ) ;
232
+
233
+ mocha . it ( 'should put and get bucket lifecycle with Filter' , async function ( ) {
234
+ // put bucket lifecycle
235
+ const params = {
236
+ Bucket : "lifecycle-bucket" ,
237
+ LifecycleConfiguration : {
238
+ Rules : [ {
239
+ ID : 'rule1' ,
240
+ Status : 'Enabled' ,
241
+ Filter : {
242
+ And : {
243
+ Prefix : 'prefix1' ,
244
+ Tags : [ {
245
+ Key : 'key1' ,
246
+ Value : 'value1'
247
+ } ]
248
+ }
249
+ } ,
250
+ Expiration : {
251
+ Days : 1
252
+ }
253
+ } ]
254
+ }
255
+ } ;
256
+ await s3 . putBucketLifecycleConfiguration ( params ) ;
257
+
258
+ // get bucket lifecycle
259
+ const res = await s3 . getBucketLifecycleConfiguration ( { Bucket : "lifecycle-bucket" } ) ;
260
+ assert . strictEqual ( res . Rules . length , 1 ) ;
261
+ assert . strictEqual ( res . Rules [ 0 ] . ID , 'rule1' ) ;
262
+ assert . strictEqual ( res . Rules [ 0 ] . Status , 'Enabled' ) ;
263
+ assert . strictEqual ( res . Rules [ 0 ] . Filter . And . Prefix , 'prefix1' ) ;
264
+ assert . strictEqual ( res . Rules [ 0 ] . Filter . And . Tags [ 0 ] . Key , 'key1' ) ;
265
+ assert . strictEqual ( res . Rules [ 0 ] . Filter . And . Tags [ 0 ] . Value , 'value1' ) ;
266
+ assert . strictEqual ( res . Rules [ 0 ] . Expiration . Days , 1 ) ;
267
+ } ) ;
268
+
269
+ mocha . it ( 'should put and get bucket lifecycle with Transitions' , async function ( ) {
270
+ // put bucket lifecycle
271
+ const params = {
272
+ Bucket : "lifecycle-bucket" ,
273
+ LifecycleConfiguration : {
274
+ Rules : [ {
275
+ ID : 'rule1' ,
276
+ Status : 'Enabled' ,
277
+ Prefix : 'prefix1-transition' ,
278
+ Transitions : [ {
279
+ Days : 1 ,
280
+ StorageClass : 'STANDARD_IA'
281
+ } ]
282
+ } ]
283
+ }
284
+ } ;
285
+ await s3 . putBucketLifecycleConfiguration ( params ) ;
286
+
287
+ // get bucket lifecycle
288
+ const res = await s3 . getBucketLifecycleConfiguration ( { Bucket : "lifecycle-bucket" } ) ;
289
+ assert . strictEqual ( res . Rules . length , 1 ) ;
290
+ assert . strictEqual ( res . Rules [ 0 ] . ID , 'rule1' ) ;
291
+ assert . strictEqual ( res . Rules [ 0 ] . Status , 'Enabled' ) ;
292
+ assert . strictEqual ( res . Rules [ 0 ] . Prefix , 'prefix1-transition' ) ;
293
+ assert . strictEqual ( res . Rules [ 0 ] . Transitions [ 0 ] . Days , 1 ) ;
294
+ assert . strictEqual ( res . Rules [ 0 ] . Transitions [ 0 ] . StorageClass , 'STANDARD_IA' ) ;
295
+ } ) ;
296
+
297
+ mocha . it ( 'should put and get bucket lifecycle with NoncurrentVersionTransition' , async function ( ) {
298
+ // put bucket lifecycle
299
+ const params = {
300
+ Bucket : "lifecycle-bucket" ,
301
+ LifecycleConfiguration : {
302
+ Rules : [ {
303
+ ID : 'rule1' ,
304
+ Status : 'Enabled' ,
305
+ Prefix : 'prefix1-noncurrent-version-transition' ,
306
+ NoncurrentVersionTransitions : [ {
307
+ NoncurrentDays : 1 ,
308
+ StorageClass : 'STANDARD_IA'
309
+ } ]
310
+ } ]
311
+ }
312
+ } ;
313
+ await s3 . putBucketLifecycleConfiguration ( params ) ;
314
+
315
+ // get bucket lifecycle
316
+ const res = await s3 . getBucketLifecycleConfiguration ( { Bucket : "lifecycle-bucket" } ) ;
317
+ assert . strictEqual ( res . Rules . length , 1 ) ;
318
+ assert . strictEqual ( res . Rules [ 0 ] . ID , 'rule1' ) ;
319
+ assert . strictEqual ( res . Rules [ 0 ] . Status , 'Enabled' ) ;
320
+ assert . strictEqual ( res . Rules [ 0 ] . Prefix , 'prefix1-noncurrent-version-transition' ) ;
321
+ assert . strictEqual ( res . Rules [ 0 ] . NoncurrentVersionTransitions [ 0 ] . NoncurrentDays , 1 ) ;
322
+ assert . strictEqual ( res . Rules [ 0 ] . NoncurrentVersionTransitions [ 0 ] . StorageClass , 'STANDARD_IA' ) ;
323
+ } ) ;
324
+
325
+ mocha . it ( 'should put and get bucket lifecycle with AbortIncompleteMultipartUpload' , async function ( ) {
326
+ // put bucket lifecycle
327
+ const params = {
328
+ Bucket : "lifecycle-bucket" ,
329
+ LifecycleConfiguration : {
330
+ Rules : [ {
331
+ ID : 'rule1' ,
332
+ Status : 'Enabled' ,
333
+ Prefix : 'prefix1-abort-incomplete' ,
334
+ AbortIncompleteMultipartUpload : {
335
+ DaysAfterInitiation : 1
336
+ }
337
+ } ]
338
+ }
339
+ } ;
340
+ await s3 . putBucketLifecycleConfiguration ( params ) ;
341
+
342
+ // get bucket lifecycle
343
+ const res = await s3 . getBucketLifecycleConfiguration ( { Bucket : "lifecycle-bucket" } ) ;
344
+ assert . strictEqual ( res . Rules . length , 1 ) ;
345
+ assert . strictEqual ( res . Rules [ 0 ] . ID , 'rule1' ) ;
346
+ assert . strictEqual ( res . Rules [ 0 ] . Status , 'Enabled' ) ;
347
+ assert . strictEqual ( res . Rules [ 0 ] . Prefix , 'prefix1-abort-incomplete' ) ;
348
+ assert . strictEqual ( res . Rules [ 0 ] . AbortIncompleteMultipartUpload . DaysAfterInitiation , 1 ) ;
349
+
350
+ } ) ;
351
+
352
+ mocha . it ( 'should put and get bucket lifecycle with Expiration' , async function ( ) {
353
+ // put bucket lifecycle
354
+ const params = {
355
+ Bucket : "lifecycle-bucket" ,
356
+ LifecycleConfiguration : {
357
+ Rules : [ {
358
+ ID : 'rule1' ,
359
+ Status : 'Enabled' ,
360
+ Prefix : 'prefix1-expiration' ,
361
+ Expiration : {
362
+ Days : 1
363
+ }
364
+ } ]
365
+ }
366
+ } ;
367
+ await s3 . putBucketLifecycleConfiguration ( params ) ;
368
+
369
+ // get bucket lifecycle
370
+ const res = await s3 . getBucketLifecycleConfiguration ( { Bucket : "lifecycle-bucket" } ) ;
371
+ assert . strictEqual ( res . Rules . length , 1 ) ;
372
+ assert . strictEqual ( res . Rules [ 0 ] . ID , 'rule1' ) ;
373
+ assert . strictEqual ( res . Rules [ 0 ] . Status , 'Enabled' ) ;
374
+ assert . strictEqual ( res . Rules [ 0 ] . Prefix , 'prefix1-expiration' ) ;
375
+ assert . strictEqual ( res . Rules [ 0 ] . Expiration . Days , 1 ) ;
376
+ } ) ;
377
+
378
+ mocha . it ( 'should put and get bucket lifecycle with NoncurrentVersionExpiration' , async function ( ) {
379
+ // put bucket lifecycle
380
+ const params = {
381
+ Bucket : "lifecycle-bucket" ,
382
+ LifecycleConfiguration : {
383
+ Rules : [ {
384
+ ID : 'rule1' ,
385
+ Status : 'Enabled' ,
386
+ Filter : {
387
+ Prefix : 'prefix1-noncurrent-version-expiration'
388
+ } ,
389
+ NoncurrentVersionExpiration : {
390
+ NoncurrentDays : 1
391
+ }
392
+ } ]
393
+ }
394
+ } ;
395
+ await s3 . putBucketLifecycleConfiguration ( params ) ;
396
+
397
+ // get bucket lifecycle
398
+ const res = await s3 . getBucketLifecycleConfiguration ( { Bucket : "lifecycle-bucket" } ) ;
399
+ assert . strictEqual ( res . Rules . length , 1 ) ;
400
+ assert . strictEqual ( res . Rules [ 0 ] . ID , 'rule1' ) ;
401
+ assert . strictEqual ( res . Rules [ 0 ] . Status , 'Enabled' ) ;
402
+ assert . strictEqual ( res . Rules [ 0 ] . Filter . Prefix , 'prefix1-noncurrent-version-expiration' ) ;
403
+ assert . strictEqual ( res . Rules [ 0 ] . NoncurrentVersionExpiration . NoncurrentDays , 1 ) ;
404
+ } ) ;
405
+
406
+ mocha . after ( async function ( ) {
407
+ await s3 . deleteBucket ( { Bucket : "lifecycle-bucket" } ) ;
408
+ } ) ;
409
+
410
+ } ) ;
198
411
} ) ;
199
412
200
413
async function test_object_ops ( bucket_name , bucket_type , caching , remote_endpoint_options ) {
0 commit comments