Skip to content

Commit 4619bab

Browse files
committed
objectTagging related tests migration
1 parent df9585e commit 4619bab

File tree

1 file changed

+137
-35
lines changed

1 file changed

+137
-35
lines changed

tests/functional/aws-node-sdk/test/multipleBackend/objectTagging/taggingAwsVersioning-putget.js

Lines changed: 137 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
const async = require('async');
2+
const {
3+
CreateBucketCommand,
4+
PutObjectCommand,
5+
DeleteObjectCommand,
6+
DeleteBucketCommand,
7+
} = require('@aws-sdk/client-s3');
28

39
const withV4 = require('../../support/withV4');
410
const BucketUtility = require('../../../lib/utility/bucket-util');
@@ -30,26 +36,34 @@ function testSuite() {
3036
withV4(sigCfg => {
3137
const bucketUtil = new BucketUtility('default', sigCfg);
3238
const s3 = bucketUtil.s3;
33-
beforeEach(done => s3.createBucket({
34-
Bucket: bucket,
35-
CreateBucketConfiguration: {
36-
LocationConstraint: awsLocation,
37-
},
38-
}, done));
39-
afterEach(done => {
40-
removeAllVersions({ Bucket: bucket }, err => {
41-
if (err) {
42-
return done(err);
43-
}
44-
return s3.deleteBucket({ Bucket: bucket }, done);
39+
40+
beforeEach(done => {
41+
const command = new CreateBucketCommand({
42+
Bucket: bucket,
43+
CreateBucketConfiguration: {
44+
LocationConstraint: awsLocation,
45+
},
4546
});
47+
s3.send(command)
48+
.then(() => done())
49+
.catch(err => done(err));
50+
});
51+
52+
afterEach(async () => {
53+
await removeAllVersions({ Bucket: bucket });
54+
await s3.send(new DeleteBucketCommand({ Bucket: bucket }));
4655
});
4756

4857
it('versioning not configured: should put/get a tag set on the ' +
4958
'latest version if no version is specified', done => {
5059
const key = `somekey-${genUniqID()}`;
5160
async.waterfall([
52-
next => s3.putObject({ Bucket: bucket, Key: key }, next),
61+
next => {
62+
const command = new PutObjectCommand({ Bucket: bucket, Key: key });
63+
s3.send(command)
64+
.then(data => next(null, data))
65+
.catch(err => next(err));
66+
},
5367
(putData, next) => putTaggingAndAssert(s3, { bucket, key, tags,
5468
expectedVersionId: false }, next),
5569
(versionId, next) => getTaggingAndAssert(s3, { bucket, key,
@@ -63,7 +77,12 @@ function testSuite() {
6377
'specific version if specified (null)', done => {
6478
const key = `somekey-${genUniqID()}`;
6579
async.waterfall([
66-
next => s3.putObject({ Bucket: bucket, Key: key }, next),
80+
next => {
81+
const command = new PutObjectCommand({ Bucket: bucket, Key: key });
82+
s3.send(command)
83+
.then(data => next(null, data))
84+
.catch(err => next(err));
85+
},
6786
(putData, next) => putTaggingAndAssert(s3, { bucket, key, tags,
6887
versionId: 'null', expectedVersionId: false }, next),
6988
(versionId, next) => getTaggingAndAssert(s3, { bucket, key,
@@ -110,7 +129,12 @@ function testSuite() {
110129
const key = `somekey-${genUniqID()}`;
111130
async.waterfall([
112131
next => enableVersioning(s3, bucket, next),
113-
next => s3.putObject({ Bucket: bucket, Key: key }, next),
132+
next => {
133+
const command = new PutObjectCommand({ Bucket: bucket, Key: key });
134+
s3.send(command)
135+
.then(data => next(null, data))
136+
.catch(err => next(err));
137+
},
114138
(putData, next) => awsGetLatestVerId(key, '',
115139
(err, awsVid) => next(err, putData.VersionId, awsVid)),
116140
(s3Vid, awsVid, next) => putNullVersionsToAws(s3, bucket, key,
@@ -131,7 +155,12 @@ function testSuite() {
131155
const key = `somekey-${genUniqID()}`;
132156
async.waterfall([
133157
next => enableVersioning(s3, bucket, next),
134-
next => s3.putObject({ Bucket: bucket, Key: key }, next),
158+
next => {
159+
const command = new PutObjectCommand({ Bucket: bucket, Key: key });
160+
s3.send(command)
161+
.then(data => next(null, data))
162+
.catch(err => next(err));
163+
},
135164
(putData, next) => putTaggingAndAssert(s3, { bucket, key, tags,
136165
expectedVersionId: putData.VersionId }, next),
137166
(versionId, next) => getTaggingAndAssert(s3, { bucket, key,
@@ -146,7 +175,12 @@ function testSuite() {
146175
const key = `somekey-${genUniqID()}`;
147176
async.waterfall([
148177
next => enableVersioning(s3, bucket, next),
149-
next => s3.putObject({ Bucket: bucket, Key: key }, next),
178+
next => {
179+
const command = new PutObjectCommand({ Bucket: bucket, Key: key });
180+
s3.send(command)
181+
.then(data => next(null, data))
182+
.catch(err => next(err));
183+
},
150184
(putData, next) => putTaggingAndAssert(s3, { bucket, key, tags,
151185
versionId: putData.VersionId,
152186
expectedVersionId: putData.VersionId }, next),
@@ -163,7 +197,12 @@ function testSuite() {
163197
const key = `somekey-${genUniqID()}`;
164198
async.waterfall([
165199
next => enableVersioning(s3, bucket, next),
166-
next => s3.putObject({ Bucket: bucket, Key: key }, next),
200+
next => {
201+
const command = new PutObjectCommand({ Bucket: bucket, Key: key });
202+
s3.send(command)
203+
.then(data => next(null, data))
204+
.catch(err => next(err));
205+
},
167206
(putData, next) => putTaggingAndAssert(s3, { bucket, key, tags,
168207
versionId: putData.VersionId,
169208
expectedVersionId: putData.VersionId }, next),
@@ -178,13 +217,25 @@ function testSuite() {
178217
const key = `somekey-${genUniqID()}`;
179218
async.waterfall([
180219
next => enableVersioning(s3, bucket, next),
181-
next => s3.putObject({ Bucket: bucket, Key: key }, next),
220+
next => {
221+
const command = new PutObjectCommand({ Bucket: bucket, Key: key });
222+
s3.send(command)
223+
.then(data => next(null, data))
224+
.catch(err => next(err));
225+
},
182226
(putData, next) => awsGetLatestVerId(key, '',
183227
(err, awsVid) => next(err, putData.VersionId, awsVid)),
184228
// put another version
185-
(s3Vid, awsVid, next) => s3.putObject({ Bucket: bucket,
186-
Key: key, Body: someBody },
187-
err => next(err, s3Vid, awsVid)),
229+
(s3Vid, awsVid, next) => {
230+
const command = new PutObjectCommand({
231+
Bucket: bucket,
232+
Key: key,
233+
Body: someBody
234+
});
235+
s3.send(command)
236+
.then(() => next(null, s3Vid, awsVid))
237+
.catch(err => next(err, s3Vid, awsVid));
238+
},
188239
(s3Vid, awsVid, next) => putTaggingAndAssert(s3, { bucket, key,
189240
tags, versionId: s3Vid, expectedVersionId: s3Vid }, err =>
190241
next(err, s3Vid, awsVid)),
@@ -196,7 +247,6 @@ function testSuite() {
196247
], done);
197248
});
198249

199-
200250
it('versioning suspended then enabled: should put/get a tag set on ' +
201251
'a specific version (null) if specified', done => {
202252
const key = `somekey-${genUniqID()}`;
@@ -222,12 +272,25 @@ function testSuite() {
222272
done => {
223273
const key = `somekey-${genUniqID()}`;
224274
async.waterfall([
225-
next => s3.putObject({ Bucket: bucket, Key: key }, next),
275+
next => {
276+
const command = new PutObjectCommand({ Bucket: bucket, Key: key });
277+
s3.send(command)
278+
.then(data => next(null, data))
279+
.catch(err => next(err));
280+
},
226281
(putData, next) => awsGetLatestVerId(key, '', next),
227282
(awsVid, next) => putTaggingAndAssert(s3, { bucket, key, tags,
228283
expectedVersionId: false }, () => next(null, awsVid)),
229-
(awsVid, next) => awsS3.deleteObject({ Bucket: awsBucket,
230-
Key: key, VersionId: awsVid }, next),
284+
(awsVid, next) => {
285+
const command = new DeleteObjectCommand({
286+
Bucket: awsBucket,
287+
Key: key,
288+
VersionId: awsVid
289+
});
290+
awsS3.send(command)
291+
.then(data => next(null, data))
292+
.catch(err => next(err));
293+
},
231294
(delData, next) => getTaggingAndAssert(s3, { bucket, key,
232295
expectedTags: tags, expectedVersionId: false,
233296
getObject: false }, next),
@@ -239,10 +302,23 @@ function testSuite() {
239302
done => {
240303
const key = `somekey-${genUniqID()}`;
241304
async.waterfall([
242-
next => s3.putObject({ Bucket: bucket, Key: key }, next),
305+
next => {
306+
const command = new PutObjectCommand({ Bucket: bucket, Key: key });
307+
s3.send(command)
308+
.then(data => next(null, data))
309+
.catch(err => next(err));
310+
},
243311
(putData, next) => awsGetLatestVerId(key, '', next),
244-
(awsVid, next) => awsS3.deleteObject({ Bucket: awsBucket,
245-
Key: key, VersionId: awsVid }, next),
312+
(awsVid, next) => {
313+
const command = new DeleteObjectCommand({
314+
Bucket: awsBucket,
315+
Key: key,
316+
VersionId: awsVid
317+
});
318+
awsS3.send(command)
319+
.then(data => next(null, data))
320+
.catch(err => next(err));
321+
},
246322
(delData, next) => putTaggingAndAssert(s3, { bucket, key, tags,
247323
expectedError: 'ServiceUnavailable' }, next),
248324
], done);
@@ -254,14 +330,27 @@ function testSuite() {
254330
const key = `somekey-${genUniqID()}`;
255331
async.waterfall([
256332
next => enableVersioning(s3, bucket, next),
257-
next => s3.putObject({ Bucket: bucket, Key: key }, next),
333+
next => {
334+
const command = new PutObjectCommand({ Bucket: bucket, Key: key });
335+
s3.send(command)
336+
.then(data => next(null, data))
337+
.catch(err => next(err));
338+
},
258339
(putData, next) => awsGetLatestVerId(key, '',
259340
(err, awsVid) => next(err, putData.VersionId, awsVid)),
260341
(s3Vid, awsVid, next) => putTaggingAndAssert(s3, { bucket, key,
261342
tags, versionId: s3Vid, expectedVersionId: s3Vid },
262343
() => next(null, s3Vid, awsVid)),
263-
(s3Vid, awsVid, next) => awsS3.deleteObject({ Bucket: awsBucket,
264-
Key: key, VersionId: awsVid }, err => next(err, s3Vid)),
344+
(s3Vid, awsVid, next) => {
345+
const command = new DeleteObjectCommand({
346+
Bucket: awsBucket,
347+
Key: key,
348+
VersionId: awsVid
349+
});
350+
awsS3.send(command)
351+
.then(() => next(null, s3Vid))
352+
.catch(err => next(err, s3Vid));
353+
},
265354
(s3Vid, next) => getTaggingAndAssert(s3, { bucket, key,
266355
versionId: s3Vid, expectedTags: tags,
267356
expectedVersionId: s3Vid, getObject: false }, next),
@@ -273,11 +362,24 @@ function testSuite() {
273362
done => {
274363
const key = `somekey-${genUniqID()}`;
275364
async.waterfall([
276-
next => s3.putObject({ Bucket: bucket, Key: key }, next),
365+
next => {
366+
const command = new PutObjectCommand({ Bucket: bucket, Key: key });
367+
s3.send(command)
368+
.then(data => next(null, data))
369+
.catch(err => next(err));
370+
},
277371
(putData, next) => awsGetLatestVerId(key, '',
278372
(err, awsVid) => next(err, putData.VersionId, awsVid)),
279-
(s3Vid, awsVid, next) => awsS3.deleteObject({ Bucket: awsBucket,
280-
Key: key, VersionId: awsVid }, err => next(err, s3Vid)),
373+
(s3Vid, awsVid, next) => {
374+
const command = new DeleteObjectCommand({
375+
Bucket: awsBucket,
376+
Key: key,
377+
VersionId: awsVid
378+
});
379+
awsS3.send(command)
380+
.then(() => next(null, s3Vid))
381+
.catch(err => next(err, s3Vid));
382+
},
281383
(s3Vid, next) => putTaggingAndAssert(s3, { bucket, key, tags,
282384
versionId: s3Vid, expectedError:
283385
'ServiceUnavailable' }, next),

0 commit comments

Comments
 (0)