Skip to content
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
"@aws-sdk/client-s3": "^3.908.0",
"@aws-sdk/credential-providers": "^3.864.0",
"@aws-sdk/middleware-retry": "^3.374.0",
"@aws-sdk/s3-request-presigner": "^3.901.0",
"@azure/storage-blob": "^12.28.0",
"@hapi/joi": "^17.1.1",
"@smithy/node-http-handler": "^3.0.0",
"arsenal": "git+https://github.com/scality/Arsenal#8.2.35",
"async": "2.6.4",
"bucketclient": "scality/bucketclient#8.2.7",
Expand Down
8 changes: 6 additions & 2 deletions tests/functional/aws-node-sdk/lib/utility/checkError.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ const assert = require('assert');

function checkError(err, code, statusCode) {
assert(err, 'Expected error but found none');
assert.strictEqual(err.code, code);
assert.strictEqual(err.statusCode, statusCode);
if (code) {
assert.strictEqual(err.name, code);
}
if (statusCode) {
assert.strictEqual(err.$metadata.httpStatusCode, statusCode);
}
}

module.exports = checkError;
2 changes: 2 additions & 0 deletions tests/functional/aws-node-sdk/lib/utility/tagging.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ const taggingTests = [
it: 'should return tags if value is an empty string' },
{ tag: { key: 'w'.repeat(129), value: 'foo' },
error: 'InvalidTag',
code: 400,
it: 'should return InvalidTag if key length is greater than 128' },
{ tag: { key: 'bar', value: 'f'.repeat(257) },
error: 'InvalidTag',
code: 400,
it: 'should return InvalidTag if key length is greater than 256',
},
];
Expand Down
35 changes: 15 additions & 20 deletions tests/functional/aws-node-sdk/lib/utility/website-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ const async = require('async');
const fs = require('fs');
const path = require('path');
const url = require('url');
const { CreateBucketCommand,
DeleteBucketCommand,
PutBucketWebsiteCommand,
DeleteObjectCommand,
PutObjectCommand } = require('@aws-sdk/client-s3');

const { makeRequest } = require('../../../raw-node/utils/makeRequest');

Expand Down Expand Up @@ -352,41 +357,31 @@ class WebsiteConfigTester {
}

static createPutBucketWebsite(s3, bucket, bucketACL, objects, done) {
s3.createBucket({ Bucket: bucket, ACL: bucketACL },
err => {
if (err) {
return done(err);
}
s3.send(new CreateBucketCommand({ Bucket: bucket, ACL: bucketACL })).then(() => {
const webConfig = new WebsiteConfigTester('index.html',
'error.html');
return s3.putBucketWebsite({ Bucket: bucket,
WebsiteConfiguration: webConfig }, err => {
if (err) {
return done(err);
}
return async.forEachOf(objects,
return s3.send(new PutBucketWebsiteCommand({ Bucket: bucket,
WebsiteConfiguration: webConfig })).then(() => async.forEachOf(objects,
(acl, object, next) => {
s3.putObject({ Bucket: bucket,
s3.send(new PutObjectCommand({ Bucket: bucket,
Key: `${object}.html`,
ACL: acl,
Body: fs.readFileSync(path.join(__dirname,
`/../../test/object/websiteFiles/${object}.html`)),
},
next);
}, done);
});
});
})).then(() => next()).catch(next);
}, done));
}).catch(err => done(err));
}

static deleteObjectsThenBucket(s3, bucket, objects, done) {
async.forEachOf(objects, (acl, object, next) => {
s3.deleteObject({ Bucket: bucket,
Key: `${object}.html` }, next);
s3.send(new DeleteObjectCommand({ Bucket: bucket,
Key: `${object}.html` })).then(() => next()).catch(next);
}, err => {
if (err) {
return done(err);
}
return s3.deleteBucket({ Bucket: bucket }, done);
return s3.send(new DeleteBucketCommand({ Bucket: bucket })).then(() => done()).catch(done);
});
}
}
Expand Down
10 changes: 7 additions & 3 deletions tests/functional/aws-node-sdk/test/object/100-continue.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const assert = require('assert');
const http = require('http');
const https = require('https');
const url = require('url');
const { CreateBucketCommand, PutObjectCommand } = require('@aws-sdk/client-s3');
const { getSignedUrl } = require('@aws-sdk/s3-request-presigner');

const withV4 = require('../support/withV4');
const BucketUtility = require('../../lib/utility/bucket-util');
Expand Down Expand Up @@ -121,17 +123,19 @@ describeSkipIfE2E('PUT public object with 100-continue header', () => {
let continueRequest;
const invalidSignedURL = `/${bucket}/${key}`;

beforeEach(() => {
beforeEach(async () => {
bucketUtil = new BucketUtility('default', sigCfg);
s3 = bucketUtil.s3;
const params = {
Bucket: bucket,
Key: key,
'Content-Length': 0,
};
const signedUrl = s3.getSignedUrl('putObject', params);
const command = new PutObjectCommand(params);
const signedUrl = await getSignedUrl(s3, command);
const { path } = url.parse(signedUrl);
continueRequest = new ContinueRequestHandler(path);
return s3.createBucket({ Bucket: bucket }).promise();
await s3.send(new CreateBucketCommand({ Bucket: bucket }));
});

afterEach(() =>
Expand Down
Loading
Loading