-
Notifications
You must be signed in to change notification settings - Fork 255
Expand file tree
/
Copy pathputVersioning.js
More file actions
64 lines (56 loc) · 1.89 KB
/
putVersioning.js
File metadata and controls
64 lines (56 loc) · 1.89 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
59
60
61
62
63
64
const assert = require('assert');
const arsenal = require('arsenal');
const {
PutBucketVersioningCommand,
GetBucketVersioningCommand,
CreateBucketCommand,
DeleteBucketCommand,
} = require('@aws-sdk/client-s3');
const { GCP } = arsenal.storage.data.external.GCP;
const { genBucketName, gcpRetry } = require('../../../utils/gcpUtils');
const { getRealAwsConfig } =
require('../../../../aws-node-sdk/test/support/awsConfig');
const credentialOne = 'gcpbackend';
const verEnabledStatus = 'Enabled';
const verDisabledStatus = 'Suspended';
const bucketName = genBucketName('putversioning');
describe('GCP: PUT Bucket Versioning', () => {
const config = getRealAwsConfig(credentialOne);
const gcpClient = new GCP(config);
before(async () => {
await gcpRetry(
gcpClient,
new CreateBucketCommand({ Bucket: bucketName }),
);
});
after(async () => {
await gcpRetry(
gcpClient,
new DeleteBucketCommand({ Bucket: bucketName }),
);
});
it('should enable bucket versioning', async () => {
await gcpClient.send(new PutBucketVersioningCommand({
Bucket: bucketName,
VersioningConfiguration: {
Status: 'Enabled',
},
}));
const res = await gcpClient.send(new GetBucketVersioningCommand({
Bucket: bucketName,
}));
assert.strictEqual(res.Status, verEnabledStatus);
});
it('should disable bucket versioning', async () => {
await gcpClient.send(new PutBucketVersioningCommand({
Bucket: bucketName,
VersioningConfiguration: {
Status: 'Suspended',
},
}));
const res = await gcpClient.send(new GetBucketVersioningCommand({
Bucket: bucketName,
}));
assert.strictEqual(res.Status, verDisabledStatus);
});
});