|
| 1 | +const assert = require('assert'); |
| 2 | +const arsenal = require('arsenal'); |
| 3 | +const { |
| 4 | + PutBucketVersioningCommand, |
| 5 | + GetBucketVersioningCommand, |
| 6 | + CreateBucketCommand, |
| 7 | + DeleteBucketCommand, |
| 8 | +} = require('@aws-sdk/client-s3'); |
| 9 | +const { GCP } = arsenal.storage.data.external.GCP; |
| 10 | +const { genBucketName, gcpRetry } = require('../../../utils/gcpUtils'); |
| 11 | +const { getRealAwsConfig } = |
| 12 | + require('../../../../aws-node-sdk/test/support/awsConfig'); |
| 13 | + |
| 14 | +const credentialOne = 'gcpbackend'; |
| 15 | +const config = getRealAwsConfig(credentialOne); |
| 16 | +const gcpClient = new GCP(config); |
| 17 | +const bucketName = genBucketName('versioning'); |
| 18 | + |
| 19 | +describe('GCP: Bucket Versioning', function testSuite() { |
| 20 | + this.timeout(120000); |
| 21 | + |
| 22 | + before(async () => { |
| 23 | + await gcpRetry(gcpClient, new CreateBucketCommand({ Bucket: bucketName })); |
| 24 | + }); |
| 25 | + |
| 26 | + after(async () => { |
| 27 | + await gcpRetry(gcpClient, new DeleteBucketCommand({ Bucket: bucketName })); |
| 28 | + }); |
| 29 | + |
| 30 | + it('should enable bucket versioning', async () => { |
| 31 | + await gcpClient.send(new PutBucketVersioningCommand({ |
| 32 | + Bucket: bucketName, |
| 33 | + VersioningConfiguration: { Status: 'Enabled' }, |
| 34 | + })); |
| 35 | + |
| 36 | + const res = await gcpClient.send( |
| 37 | + new GetBucketVersioningCommand({ Bucket: bucketName })); |
| 38 | + assert.strictEqual(res.Status, 'Enabled'); |
| 39 | + }); |
| 40 | + |
| 41 | + it('should disable bucket versioning', async () => { |
| 42 | + await gcpClient.send(new PutBucketVersioningCommand({ |
| 43 | + Bucket: bucketName, |
| 44 | + VersioningConfiguration: { Status: 'Suspended' }, |
| 45 | + })); |
| 46 | + |
| 47 | + const res = await gcpClient.send( |
| 48 | + new GetBucketVersioningCommand({ Bucket: bucketName })); |
| 49 | + assert.strictEqual(res.Status, 'Suspended'); |
| 50 | + }); |
| 51 | +}); |
0 commit comments