-
Notifications
You must be signed in to change notification settings - Fork 256
Expand file tree
/
Copy pathbucketDeleteLifecycle.js
More file actions
58 lines (54 loc) · 2.09 KB
/
bucketDeleteLifecycle.js
File metadata and controls
58 lines (54 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const assert = require('assert');
const async = require('async');
const { bucketPut } = require('../../../lib/api/bucketPut');
const bucketPutLifecycle = require('../../../lib/api/bucketDeleteLifecycle');
const bucketDeleteLifecycle = require('../../../lib/api/bucketDeleteLifecycle');
const { cleanup,
DummyRequestLogger,
makeAuthInfo }
= require('../helpers');
const metadata = require('../../../lib/metadata/wrapper');
const log = new DummyRequestLogger();
const authInfo = makeAuthInfo('accessKey1');
const bucketName = 'bucketname';
function _makeRequest(includeXml) {
const request = {
bucketName,
headers: { host: `${bucketName}.s3.amazonaws.com` },
url: '/',
actionImplicitDenies: false,
};
if (includeXml) {
request.post = '<LifecycleConfiguration ' +
'xmlns="http://s3.amazonaws.com/doc/2006-03-01/">' +
'<Rule><ID></ID><Filter></Filter>' +
'<Status>Enabled</Status>' +
'<Expiration><Days>1</Days></Expiration>' +
'</Rule></LifecycleConfiguration>';
}
return request;
}
describe('deleteBucketLifecycle API', () => {
before(() => cleanup());
beforeEach(done => bucketPut(authInfo, _makeRequest(), log, done));
afterEach(() => cleanup());
it('should not return an error even if no lifecycle put', done => {
bucketDeleteLifecycle(authInfo, _makeRequest(), log, err => {
assert.equal(err, null, `Err deleting lifecycle: ${err}`);
done();
});
});
it('should delete bucket lifecycle', done => {
async.series([
next => bucketPutLifecycle(authInfo, _makeRequest(true), log, next),
next => bucketDeleteLifecycle(authInfo, _makeRequest(), log, next),
next => metadata.getBucket(bucketName, log, next),
], (err, results) => {
assert.equal(err, null, `Expected success, got error: ${err}`);
const bucket = results[2];
const lifecycleConfig = bucket.getLifecycleConfiguration();
assert.equal(lifecycleConfig, null);
done();
});
});
});