Compare commits

...

6 Commits

Author SHA1 Message Date
Jordi Bertran de Balanda 5f67869638 more tests 2022-04-29 17:49:31 +02:00
Jordi Bertran de Balanda 574cb728a5 fix MPU 2022-04-29 16:26:46 +02:00
Jordi Bertran de Balanda 4f08f38189 deepStrictEqual no longer works, switch to `is` 2022-04-29 16:26:46 +02:00
Jordi Bertran de Balanda 7eb4fbe840 CLDSRV-174 - fix multiple backend tests
(cherry picked from commit e38c4290e6)
2022-04-29 16:01:41 +02:00
Jordi Bertran de Balanda 555a036d85 catch up de 2022-04-29 15:16:13 +02:00
Guillaume Hivert decc16e77b Test with new Arsenal 2022-04-29 14:42:08 +02:00
14 changed files with 64 additions and 32 deletions

View File

@ -2,7 +2,7 @@ const { errors } = require('arsenal');
const {
parseRangeSpec,
parseRange,
} = require('arsenal/lib/network/http/utils');
} = require('arsenal').network.http.utils;
const constants = require('../../../../constants');
const setPartRanges = require('./setPartRanges');

View File

@ -1,5 +1,3 @@
const { errors } = require('arsenal');
const abortMultipartUpload = require('./apiUtils/object/abortMultipartUpload');
const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const isLegacyAWSBehavior = require('../utilities/legacyAWSBehavior');
@ -29,10 +27,10 @@ function multipartDelete(authInfo, request, log, callback) {
request.method, destinationBucket);
const location = destinationBucket ?
destinationBucket.getLocationConstraint() : null;
if (err && err !== errors.NoSuchUpload) {
if (err && !err.is.NoSuchUpload) {
return callback(err, corsHeaders);
}
if (err === errors.NoSuchUpload && isLegacyAWSBehavior(location)) {
if (err && err.is.NoSuchUpload && isLegacyAWSBehavior(location)) {
log.trace('did not find valid mpu with uploadId', {
method: 'multipartDelete',
uploadId,

View File

@ -1,5 +1,5 @@
const { errors, s3middleware } = require('arsenal');
const { parseRange } = require('arsenal/lib/network/http/utils');
const { parseRange } = require('arsenal').network.http.utils;
const data = require('../data/wrapper');

View File

@ -1,6 +1,6 @@
const { errors, s3middleware } = require('arsenal');
const validateHeaders = s3middleware.validateConditionalHeaders;
const { parseRange } = require('arsenal/lib/network/http/utils');
const { parseRange } = require('arsenal').network.http.utils;
const { decodeVersionId } = require('./apiUtils/object/versioning');
const collectCorsHeaders = require('../utilities/collectCorsHeaders');

View File

@ -20,7 +20,7 @@
"homepage": "https://github.com/scality/S3#readme",
"dependencies": {
"@hapi/joi": "^17.1.0",
"arsenal": "git+https://github.com/scality/arsenal#7.10.15",
"arsenal": "git+https://github.com/scality/arsenal#feature/ARSN-175-fix-errors-backwards",
"async": "~2.5.0",
"aws-sdk": "2.905.0",
"azure-storage": "^2.1.0",

View File

@ -71,7 +71,7 @@ describe('Healthcheck response', () => {
const azureLocationNonExistContainerError =
results[azureLocationNonExistContainer].error;
if (err) {
assert.strictEqual(err, errors.InternalError,
assert(err.is.InternalError,
`got unexpected err in clientCheck: ${err}`);
assert(azureLocationNonExistContainerError.startsWith(
'The specified container is being deleted.'));

View File

@ -513,7 +513,7 @@ describe('Multipart Upload API with AWS Backend', function mpuTestSuite() {
const fakeKey = `key-${Date.now()}`;
const delParams = getDeleteParams(fakeKey, fakeUploadId);
multipartDelete(authInfo, delParams, log, err => {
assert.equal(err, errors.NoSuchUpload,
assert(err.is.NoSuchUpload,
`Error aborting MPU: ${err}`);
done();
});

View File

@ -2,6 +2,7 @@ const assert = require('assert');
const async = require('async');
const { parseString } = require('xml2js');
const AWS = require('aws-sdk');
const { errors } = require('arsenal');
const { cleanup, DummyRequestLogger, makeAuthInfo }
= require('../unit/helpers');
@ -147,8 +148,7 @@ errorPutCopyPart) {
return objectPutCopyPart(authInfo, copyPartReq,
bucketName, sourceObjName, undefined, log, (err, copyResult) => {
if (errorPutCopyPart) {
assert.strictEqual(err.code, errorPutCopyPart.statusCode);
assert(err[errorPutCopyPart.code]);
assert.strictEqual(err.is[errorPutCopyPart.type], true);
return cb();
}
assert.strictEqual(err, null);
@ -293,7 +293,7 @@ function testSuite() {
it('should return error 403 AccessDenied copying part to a ' +
'different AWS location without object READ access',
done => {
const errorPutCopyPart = { code: 'AccessDenied', statusCode: 403 };
const errorPutCopyPart = errors.AccessDenied;
copyPutPart(null, awsLocation, awsLocation2, 'localhost', done,
errorPutCopyPart);
});

View File

@ -425,7 +425,7 @@ describe('versioning helpers', () => {
'foobucket', mockBucketMD, testCase.objMD,
testCase.reqVersionId, null, (err, options) => {
if (testCase.expectedError) {
assert.strictEqual(err, testCase.expectedError);
assert(err.is[testCase.expectedError.type]);
} else {
assert.ifError(err);
assert.deepStrictEqual(options, testCase.expectedRes);

View File

@ -3,8 +3,6 @@ const async = require('async');
const { parseString } = require('xml2js');
const sinon = require('sinon');
const { errors } = require('arsenal');
const { cleanup, DummyRequestLogger } = require('../helpers');
const { config } = require('../../../lib/Config');
const services = require('../../../lib/services');
@ -126,7 +124,7 @@ describe('Multipart Delete API', () => {
'exist and legacyAwsBehavior set to true',
done => {
_createAndAbortMpu(true, true, eastLocation, err => {
assert.strictEqual(err, errors.NoSuchUpload,
assert(err.is.NoSuchUpload,
`Expected NoSuchUpload, got ${err}`);
done();
});

View File

@ -1716,7 +1716,7 @@ describe('Multipart Upload API', () => {
bucketPut(authInfo, bucketPutRequest, log, () =>
objectPutPart(authInfo, partRequest, undefined, log, err => {
assert.strictEqual(err, errors.NoSuchUpload);
assert(err.is.NoSuchUpload);
done();
})
);
@ -1831,7 +1831,7 @@ describe('Multipart Upload API', () => {
completeMultipartUpload(authInfo, completeRequest, log, err => {
// expect a failure here because we could not
// remove the overview key
assert.strictEqual(err, errors.InternalError);
assert(err.is.InternalError);
next(null, eTag, testUploadId);
});
},
@ -2054,7 +2054,7 @@ describe('complete mpu with versioning', () => {
completeMultipartUpload(authInfo, completeRequest, log, err => {
// expect a failure here because we could not
// remove the overview key
assert.strictEqual(err, errors.InternalError);
assert(err.is.InternalError);
next(null, eTag, testUploadId);
});
},

View File

@ -208,8 +208,7 @@ describe('putObjectACL API', () => {
(err, resHeaders) => {
assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`);
objectPutACL(authInfo, testObjACLRequest, log, err => {
assert.strictEqual(err,
errors.UnresolvableGrantByEmailAddress);
assert(err.is.UnresolvableGrantByEmailAddress);
done();
});
});
@ -342,8 +341,7 @@ describe('putObjectACL API', () => {
(err, resHeaders) => {
assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`);
objectPutACL(authInfo, testObjACLRequest, log, err => {
assert.strictEqual(err,
errors.UnresolvableGrantByEmailAddress);
assert(err.is.UnresolvableGrantByEmailAddress);
done();
});
});

View File

@ -1,5 +1,3 @@
const { errors } = require('arsenal');
const assert = require('assert');
const { cleanup, DummyRequestLogger } = require('../helpers');
@ -45,7 +43,7 @@ describe('bucket creation', () => {
it('should return 409 if try to recreate in non-us-east-1', done => {
createBucket(authInfo, bucketName, headers,
normalBehaviorLocationConstraint, log, err => {
assert.strictEqual(err, errors.BucketAlreadyOwnedByYou);
assert(err.is.BucketAlreadyOwnedByYou);
done();
});
});
@ -64,7 +62,7 @@ describe('bucket creation', () => {
it('should return 409 if try to recreate in us-east-1', done => {
createBucket(authInfo, bucketName, headers,
specialBehaviorLocationConstraint, log, err => {
assert.strictEqual(err, errors.BucketAlreadyOwnedByYou);
assert(err.is.BucketAlreadyOwnedByYou);
done();
});
});

View File

@ -111,6 +111,23 @@
dependencies:
dayjs "^1.10.5"
"@sideway/address@^4.1.3":
version "4.1.4"
resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.4.tgz#03dccebc6ea47fdc226f7d3d1ad512955d4783f0"
integrity sha512-7vwq+rOHVWjyXxVlR76Agnvhy8I9rpzjosTESvmhNeXOXdZZB15Fl+TI9x1SiHZH5Jv2wTGduSxFDIaq0m3DUw==
dependencies:
"@hapi/hoek" "^9.0.0"
"@sideway/formula@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@sideway/formula/-/formula-3.0.0.tgz#fe158aee32e6bd5de85044be615bc08478a0a13c"
integrity sha512-vHe7wZ4NOXVfkoRb8T5otiENVlT7a3IAiw7H5M2+GO+9CDgcVUUsX1zalAztCmwyOr2RUTGJdgB+ZvSVqmdHmg==
"@sideway/pinpoint@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@sideway/pinpoint/-/pinpoint-2.0.0.tgz#cff8ffadc372ad29fd3f78277aeb29e632cc70df"
integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==
"@sinonjs/commons@^1.6.0", "@sinonjs/commons@^1.7.0", "@sinonjs/commons@^1.8.3":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d"
@ -144,6 +161,16 @@
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==
"@types/async@^3.2.12":
version "3.2.13"
resolved "https://registry.yarnpkg.com/@types/async/-/async-3.2.13.tgz#ec023074c70180d17cbc9117ddc3cec2f3894ea4"
integrity sha512-7Q3awrhnvm89OzfsmqeqRQh8mh+8Pxfgq1UvSAn2nWQ5y/F3+NrbIF0RbkWq8+5dY99ozgap2b3DNBNwjLVOxw==
"@types/utf8@^3.0.1":
version "3.0.1"
resolved "https://registry.yarnpkg.com/@types/utf8/-/utf8-3.0.1.tgz#bf081663d4fff05ee63b41f377a35f8b189f7e5b"
integrity sha512-1EkWuw7rT3BMz2HpmcEOr/HL61mWNA6Ulr/KdbXR9AI0A55wD4Qfv8hizd8Q1DnknSIzzDvQmvvY/guvX7jjZA==
JSONStream@^1.0.0:
version "1.3.5"
resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0"
@ -391,11 +418,12 @@ arraybuffer.slice@~0.0.7:
resolved "https://registry.yarnpkg.com/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz#3bbc4275dd584cc1b10809b89d4e8b63a69e7675"
integrity sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog==
"arsenal@git+https://github.com/scality/arsenal#7.10.15":
version "7.10.15"
resolved "git+https://github.com/scality/arsenal#310834c237da624800ea6b4e291045808aa9bf80"
"arsenal@git+https://github.com/scality/arsenal#feature/ARSN-175-fix-errors-backwards":
version "7.10.21"
resolved "git+https://github.com/scality/arsenal#fea286a9722971a585e527f391dfaa1ee921435e"
dependencies:
"@hapi/joi" "^15.1.0"
"@types/async" "^3.2.12"
"@types/utf8" "^3.0.1"
JSONStream "^1.0.0"
agentkeepalive "^4.1.3"
ajv "6.12.2"
@ -412,6 +440,7 @@ arraybuffer.slice@~0.0.7:
hdclient scality/hdclient#1.1.0
ioredis "^4.28.5"
ipaddr.js "1.9.1"
joi "^17.6.0"
level "~5.0.1"
level-sublevel "~6.6.5"
mongodb "^3.0.1"
@ -2891,6 +2920,17 @@ jmespath@0.16.0:
resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.16.0.tgz#b15b0a85dfd4d930d43e69ed605943c802785076"
integrity sha512-9FzQjJ7MATs1tSpnco1K6ayiYE3figslrXA72G2HQ/n76RzvYlofyi5QM+iX4YRs/pu3yzxlVQSST23+dMDknw==
joi@^17.6.0:
version "17.6.0"
resolved "https://registry.yarnpkg.com/joi/-/joi-17.6.0.tgz#0bb54f2f006c09a96e75ce687957bd04290054b2"
integrity sha512-OX5dG6DTbcr/kbMFj0KGYxuew69HPcAE3K/sZpEV2nP6e/j/C0HV+HNiBPCASxdx5T7DMoa0s8UeHWMnb6n2zw==
dependencies:
"@hapi/hoek" "^9.0.0"
"@hapi/topo" "^5.0.0"
"@sideway/address" "^4.1.3"
"@sideway/formula" "^3.0.0"
"@sideway/pinpoint" "^2.0.0"
"js-tokens@^3.0.0 || ^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"