Compare commits

...

8 Commits

Author SHA1 Message Date
Jordi Bertran de Balanda 1923937dc6 CLDSRV-174 - fix test on non-deserialized err 2022-04-26 18:27:39 +02:00
Jordi Bertran de Balanda ecc7513412 fix err condition 2022-04-26 18:27:39 +02:00
Jordi Bertran de Balanda e38c4290e6 CLDSRV-174 - fix multiple backend tests 2022-04-26 18:27:39 +02:00
Jordi Bertran de Balanda aff7e77f73 CLDSRV-174 - correct flaky time comparison
Locally, the time comparison test
'"return PreconditionFailed if request header includes "if-unmodified-since"'
is flaky.

Intuitively, this is because the successive side effects on the master
date we use provokes the generation of 2 dates:
- if we are lucky, the scheduler and inherent time computation
  inaccuracies introduce a sufficient delay for one date to be strictly
  superior to the other, so the test succeeds
- if we're not, they're the same, so the test fails
2022-04-26 18:27:39 +02:00
Jordi Bertran de Balanda 3b3282704e CLDSRV-174 - fix tests 2022-04-26 18:27:39 +02:00
Jordi Bertran de Balanda 223d19b0a8 CLDSRV-174 - fix file-like import paths
Now that we have a build step and the application doesn't have the same
directory structure to access Arsenal's code, we can't access `utils`
any longer.

As a general rule we should never do file-like imports when the modules
we depend on provide an index.
2022-04-26 18:27:39 +02:00
Jordi Bertran de Balanda 46b65f39e5 CLDSRV-174 - fix CI 2022-04-26 18:27:39 +02:00
Jordi Bertran de Balanda 884132e693 CLDSRV-174 - bump arsenal, make the easy changes
Using a few sed scripts, we make most of the changes automatically, then
fix linting.
2022-04-26 18:27:39 +02:00
65 changed files with 298 additions and 292 deletions

View File

@ -33,7 +33,7 @@ RUN cd /tmp \
&& rm -rf /tmp/Python-$PY_VERSION.tgz && rm -rf /tmp/Python-$PY_VERSION.tgz
RUN yarn cache clean \ RUN yarn cache clean \
&& yarn install --production --ignore-optional --ignore-engines --network-concurrency 1 \ && yarn install --production --ignore-optional --ignore-engines --network-concurrency 1 \
&& apt-get autoremove --purge -y python git build-essential \ && apt-get autoremove --purge -y python git build-essential \
&& rm -rf /var/lib/apt/lists/* \ && rm -rf /var/lib/apt/lists/* \
&& yarn cache clean \ && yarn cache clean \

View File

@ -49,7 +49,7 @@ function updateRequestContexts(request, requestContexts, apiMethod, log, cb) {
return metadata.getObjectMD(bucketName, objectKey, { versionId: reqVersionId }, log, return metadata.getObjectMD(bucketName, objectKey, { versionId: reqVersionId }, log,
(err, objMD) => { (err, objMD) => {
if (err) { if (err) {
if (err.NoSuchKey) { if (err.is.NoSuchKey) {
return next(); return next();
} }
log.trace('error getting request object tags'); log.trace('error getting request object tags');

View File

@ -22,7 +22,7 @@ function addToUsersBucket(canonicalID, bucketName, log, cb) {
// Get new format usersBucket to see if it exists // Get new format usersBucket to see if it exists
return metadata.getBucket(usersBucket, log, (err, usersBucketAttrs) => { return metadata.getBucket(usersBucket, log, (err, usersBucketAttrs) => {
if (err && !err.NoSuchBucket && !err.BucketAlreadyExists) { if (err && !err.is.NoSuchBucket && !err.is.BucketAlreadyExists) {
return cb(err); return cb(err);
} }
const splitter = usersBucketAttrs ? const splitter = usersBucketAttrs ?
@ -36,7 +36,7 @@ function addToUsersBucket(canonicalID, bucketName, log, cb) {
usersBucket : oldUsersBucket; usersBucket : oldUsersBucket;
return metadata.putObjectMD(usersBucketBeingCalled, key, return metadata.putObjectMD(usersBucketBeingCalled, key,
omVal, {}, log, err => { omVal, {}, log, err => {
if (err && err.NoSuchBucket) { if (err && err.is.NoSuchBucket) {
// There must be no usersBucket so createBucket // There must be no usersBucket so createBucket
// one using the new format // one using the new format
log.trace('users bucket does not exist, ' + log.trace('users bucket does not exist, ' +
@ -57,8 +57,7 @@ function addToUsersBucket(canonicalID, bucketName, log, cb) {
// error with respect // error with respect
// to the usersBucket. // to the usersBucket.
if (err && if (err &&
err !== !err.is.BucketAlreadyExists) {
errors.BucketAlreadyExists) {
log.error('error from metadata', { log.error('error from metadata', {
error: err, error: err,
}); });
@ -206,7 +205,7 @@ function createBucket(authInfo, bucketName, headers,
}, },
getAnyExistingBucketInfo: function getAnyExistingBucketInfo(callback) { getAnyExistingBucketInfo: function getAnyExistingBucketInfo(callback) {
metadata.getBucket(bucketName, log, (err, data) => { metadata.getBucket(bucketName, log, (err, data) => {
if (err && err.NoSuchBucket) { if (err && err.is.NoSuchBucket) {
return callback(null, 'NoBucketYet'); return callback(null, 'NoBucketYet');
} }
if (err) { if (err) {

View File

@ -16,7 +16,7 @@ function _deleteMPUbucket(destinationBucketName, log, cb) {
`${mpuBucketPrefix}${destinationBucketName}`; `${mpuBucketPrefix}${destinationBucketName}`;
return metadata.deleteBucket(mpuBucketName, log, err => { return metadata.deleteBucket(mpuBucketName, log, err => {
// If the mpu bucket does not exist, just move on // If the mpu bucket does not exist, just move on
if (err && err.NoSuchBucket) { if (err && err.is.NoSuchBucket) {
return cb(); return cb();
} }
return cb(err); return cb(err);
@ -90,7 +90,7 @@ function deleteBucket(authInfo, bucketMD, bucketName, canonicalID, log, cb) {
log, (err, objectsListRes) => { log, (err, objectsListRes) => {
// If no shadow bucket ever created, no ongoing MPU's, so // If no shadow bucket ever created, no ongoing MPU's, so
// continue with deletion // continue with deletion
if (err && err.NoSuchBucket) { if (err && err.is.NoSuchBucket) {
return next(); return next();
} }
if (err) { if (err) {

View File

@ -11,16 +11,16 @@ function deleteUserBucketEntry(bucketName, canonicalID, log, cb) {
metadata.deleteObjectMD(usersBucket, keyForUserBucket, {}, log, error => { metadata.deleteObjectMD(usersBucket, keyForUserBucket, {}, log, error => {
// If the object representing the bucket is not in the // If the object representing the bucket is not in the
// users bucket just continue // users bucket just continue
if (error && error.NoSuchKey) { if (error && error.is.NoSuchKey) {
return cb(null); return cb(null);
// BACKWARDS COMPATIBILITY: Remove this once no longer // BACKWARDS COMPATIBILITY: Remove this once no longer
// have old user bucket format // have old user bucket format
} else if (error && error.NoSuchBucket) { } else if (error && error.is.NoSuchBucket) {
const keyForUserBucket2 = createKeyForUserBucket(canonicalID, const keyForUserBucket2 = createKeyForUserBucket(canonicalID,
oldSplitter, bucketName); oldSplitter, bucketName);
return metadata.deleteObjectMD(oldUsersBucket, keyForUserBucket2, return metadata.deleteObjectMD(oldUsersBucket, keyForUserBucket2,
{}, log, error => { {}, log, error => {
if (error && !error.NoSuchKey) { if (error && !error.is.NoSuchKey) {
log.error('from metadata while deleting user bucket', log.error('from metadata while deleting user bucket',
{ error }); { error });
return cb(error); return cb(error);

View File

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

View File

@ -292,7 +292,7 @@ function versioningPreprocessing(bucketName, bucketMD, objectKey, objMD,
// it's possible there was a concurrent request to // it's possible there was a concurrent request to
// delete the null version, so proceed with putting a // delete the null version, so proceed with putting a
// new version // new version
if (err === errors.NoSuchKey) { if (err === errors.is.NoSuchKey) {
return next(null, options); return next(null, options);
} }
return next(errors.InternalError); return next(errors.InternalError);

View File

@ -341,7 +341,7 @@ function completeMultipartUpload(authInfo, request, log, callback) {
if (err) { if (err) {
// TODO: check AWS error when user requested a specific // TODO: check AWS error when user requested a specific
// version before any versions have been put // version before any versions have been put
const logLvl = err === errors.BadRequest ? const logLvl = err.is.BadRequest ?
'debug' : 'error'; 'debug' : 'error';
log[logLvl]('error getting versioning info', { log[logLvl]('error getting versioning info', {
error: err, error: err,

View File

@ -210,10 +210,10 @@ function getObjMetadataAndDelete(authInfo, canonicalID, request,
(versionId, callback) => metadataGetObject(bucketName, entry.key, (versionId, callback) => metadataGetObject(bucketName, entry.key,
versionId, log, (err, objMD) => { versionId, log, (err, objMD) => {
// if general error from metadata return error // if general error from metadata return error
if (err && !err.NoSuchKey) { if (err && !err.is.NoSuchKey) {
return callback(err); return callback(err);
} }
if (err && err.NoSuchKey) { if (err && err.is.NoSuchKey) {
const verCfg = bucket.getVersioningConfiguration(); const verCfg = bucket.getVersioningConfiguration();
// To adhere to AWS behavior, create a delete marker // To adhere to AWS behavior, create a delete marker
// if trying to delete an object that does not exist // if trying to delete an object that does not exist
@ -386,11 +386,11 @@ function multiObjectDelete(authInfo, request, log, callback) {
return vault.checkPolicies(requestContextParams, authInfo.getArn(), return vault.checkPolicies(requestContextParams, authInfo.getArn(),
log, (err, authorizationResults) => { log, (err, authorizationResults) => {
// there were no policies so received a blanket AccessDenied // there were no policies so received a blanket AccessDenied
if (err && err.AccessDenied) { if (err && err.is.AccessDenied) {
objects.forEach(entry => { objects.forEach(entry => {
errorResults.push({ errorResults.push({
entry, entry,
error: errors.AccessDenied }); error: errors.is.AccessDenied });
}); });
// send empty array for inPlay // send empty array for inPlay
return next(null, quietSetting, errorResults, []); return next(null, quietSetting, errorResults, []);

View File

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

View File

@ -1,5 +1,5 @@
const { errors, s3middleware } = require('arsenal'); 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'); const data = require('../data/wrapper');

View File

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

View File

@ -182,7 +182,7 @@ function objectPutCopyPart(authInfo, request, sourceBucket,
sourceLocationConstraintName, next) { sourceLocationConstraintName, next) {
return metadata.getBucket(mpuBucketName, log, return metadata.getBucket(mpuBucketName, log,
(err, mpuBucket) => { (err, mpuBucket) => {
if (err && err.NoSuchBucket) { if (err && err.is.NoSuchBucket) {
return next(errors.NoSuchUpload); return next(errors.NoSuchUpload);
} }
if (err) { if (err) {
@ -211,7 +211,7 @@ function objectPutCopyPart(authInfo, request, sourceBucket,
return metadata.getObjectMD(mpuBucketName, mpuOverviewKey, return metadata.getObjectMD(mpuBucketName, mpuOverviewKey,
null, log, (err, res) => { null, log, (err, res) => {
if (err) { if (err) {
if (err.NoSuchKey) { if (err.is.NoSuchKey) {
return next(errors.NoSuchUpload); return next(errors.NoSuchUpload);
} }
log.error('error getting overview object from ' + log.error('error getting overview object from ' +
@ -263,7 +263,7 @@ function objectPutCopyPart(authInfo, request, sourceBucket,
metadata.getObjectMD(mpuBucketName, partKey, {}, log, metadata.getObjectMD(mpuBucketName, partKey, {}, log,
(err, result) => { (err, result) => {
// If there is nothing being overwritten just move on // If there is nothing being overwritten just move on
if (err && !err.NoSuchKey) { if (err && !err.is.NoSuchKey) {
log.debug('error getting current part (if any)', log.debug('error getting current part (if any)',
{ error: err }); { error: err });
return next(err); return next(err);

View File

@ -94,7 +94,7 @@ function objectPutPart(authInfo, request, streamingV4Params, log,
// Get the destination bucket. // Get the destination bucket.
next => metadata.getBucket(bucketName, log, next => metadata.getBucket(bucketName, log,
(err, destinationBucket) => { (err, destinationBucket) => {
if (err && err.NoSuchBucket) { if (err && err.is.NoSuchBucket) {
return next(errors.NoSuchBucket, destinationBucket); return next(errors.NoSuchBucket, destinationBucket);
} }
if (err) { if (err) {
@ -142,7 +142,7 @@ function objectPutPart(authInfo, request, streamingV4Params, log,
(destinationBucket, cipherBundle, next) => (destinationBucket, cipherBundle, next) =>
metadata.getBucket(mpuBucketName, log, metadata.getBucket(mpuBucketName, log,
(err, mpuBucket) => { (err, mpuBucket) => {
if (err && err.NoSuchBucket) { if (err && err.is.NoSuchBucket) {
return next(errors.NoSuchUpload, destinationBucket); return next(errors.NoSuchUpload, destinationBucket);
} }
if (err) { if (err) {
@ -252,7 +252,7 @@ function objectPutPart(authInfo, request, streamingV4Params, log,
return metadata.getObjectMD(mpuBucketName, partKey, {}, log, return metadata.getObjectMD(mpuBucketName, partKey, {}, log,
(err, res) => { (err, res) => {
// If there is no object with the same key, continue. // If there is no object with the same key, continue.
if (err && !err.NoSuchKey) { if (err && !err.is.NoSuchKey) {
log.error('error getting current part (if any)', { log.error('error getting current part (if any)', {
error: err, error: err,
method: 'objectPutPart::metadata.getObjectMD', method: 'objectPutPart::metadata.getObjectMD',

View File

@ -147,7 +147,7 @@ function websiteGet(request, log, callback) {
'bucketGet', constants.publicId, null, log, request); 'bucketGet', constants.publicId, null, log, request);
// if index object does not exist and bucket is private AWS // if index object does not exist and bucket is private AWS
// returns 403 - AccessDenied error. // returns 403 - AccessDenied error.
if (err === errors.NoSuchKey && !bucketAuthorized) { if (err.is.NoSuchKey && !bucketAuthorized) {
returnErr = errors.AccessDenied; returnErr = errors.AccessDenied;
} }
return _errorActions(returnErr, return _errorActions(returnErr,

View File

@ -107,7 +107,7 @@ function websiteHead(request, log, callback) {
'bucketGet', constants.publicId, null, log, request); 'bucketGet', constants.publicId, null, log, request);
// if index object does not exist and bucket is private AWS // if index object does not exist and bucket is private AWS
// returns 403 - AccessDenied error. // returns 403 - AccessDenied error.
if (err === errors.NoSuchKey && !bucketAuthorized) { if (err.is.NoSuchKey && !bucketAuthorized) {
returnErr = errors.AccessDenied; returnErr = errors.AccessDenied;
} }
return _errorActions(returnErr, routingRules, return _errorActions(returnErr, routingRules,

View File

@ -84,7 +84,7 @@ class AzureClient {
return metadata.listMultipartUploads(mpuBucketName, listingParams, return metadata.listMultipartUploads(mpuBucketName, listingParams,
log, (err, mpuList) => { log, (err, mpuList) => {
if (err && !err.NoSuchBucket) { if (err && !err.is.NoSuchBucket) {
log.error('Error listing MPUs for Azure delete', log.error('Error listing MPUs for Azure delete',
{ error: err, dataStoreName }); { error: err, dataStoreName });
return cb(errors.ServiceUnavailable); return cb(errors.ServiceUnavailable);

View File

@ -85,7 +85,7 @@ function _retryDelete(objectGetInfo, log, count, cb) {
} }
return client.delete(objectGetInfo, log.getSerializedUids(), err => { return client.delete(objectGetInfo, log.getSerializedUids(), err => {
if (err) { if (err) {
if (err.ObjNotFound) { if (err.is.ObjNotFound) {
log.info('no such key in datastore', log.info('no such key in datastore',
{ objectGetInfo, implName, moreRetries: 'no' }); { objectGetInfo, implName, moreRetries: 'no' });
return cb(err); return cb(err);
@ -264,7 +264,7 @@ const data = {
return; return;
} }
_retryDelete(clientGetInfo, log, 0, err => { _retryDelete(clientGetInfo, log, 0, err => {
if (err && !err.ObjNotFound) { if (err && !err.is.ObjNotFound) {
log.error('delete error from datastore', log.error('delete error from datastore',
{ error: err, key: objectGetInfo.key, moreRetries: 'no' }); { error: err, key: objectGetInfo.key, moreRetries: 'no' });
} }

View File

@ -49,7 +49,7 @@ class BucketClientInterface {
getBucketAndObject(bucketName, objName, params, log, cb) { getBucketAndObject(bucketName, objName, params, log, cb) {
this.client.getBucketAndObject(bucketName, objName, this.client.getBucketAndObject(bucketName, objName,
log.getSerializedUids(), (err, data) => { log.getSerializedUids(), (err, data) => {
if (err && (!err.NoSuchKey && !err.ObjNotFound)) { if (err && (!err.is.NoSuchKey && !err.is.ObjNotFound)) {
return cb(err); return cb(err);
} }
return cb(null, JSON.parse(data)); return cb(null, JSON.parse(data));

View File

@ -84,7 +84,7 @@ class BucketFileInterface {
createBucket(bucketName, bucketMD, log, cb) { createBucket(bucketName, bucketMD, log, cb) {
this.getBucketAttributes(bucketName, log, err => { this.getBucketAttributes(bucketName, log, err => {
if (err && err !== errors.NoSuchBucket) { if (err && !err.is.NoSuchBucket) {
return cb(err); return cb(err);
} }
if (err === undefined) { if (err === undefined) {
@ -102,7 +102,7 @@ class BucketFileInterface {
.withRequestLogger(log) .withRequestLogger(log)
.get(bucketName, {}, (err, data) => { .get(bucketName, {}, (err, data) => {
if (err) { if (err) {
if (err.ObjNotFound) { if (err.is.ObjNotFound) {
return cb(errors.NoSuchBucket); return cb(errors.NoSuchBucket);
} }
const logObj = { const logObj = {
@ -126,7 +126,7 @@ class BucketFileInterface {
db.withRequestLogger(log) db.withRequestLogger(log)
.get(objName, params, (err, objAttr) => { .get(objName, params, (err, objAttr) => {
if (err) { if (err) {
if (err.ObjNotFound) { if (err.is.ObjNotFound) {
return cb(null, { return cb(null, {
bucket: bucketAttr.serialize(), bucket: bucketAttr.serialize(),
}); });
@ -219,7 +219,7 @@ class BucketFileInterface {
} }
db.withRequestLogger(log).get(objName, params, (err, data) => { db.withRequestLogger(log).get(objName, params, (err, data) => {
if (err) { if (err) {
if (err.ObjNotFound) { if (err.is.ObjNotFound) {
return cb(errors.NoSuchKey); return cb(errors.NoSuchKey);
} }
const logObj = { const logObj = {

View File

@ -719,7 +719,7 @@ function batchDelete(request, response, log, callback) {
log.trace('batch delete locations', { locations }); log.trace('batch delete locations', { locations });
return async.eachLimit(locations, 5, (loc, next) => { return async.eachLimit(locations, 5, (loc, next) => {
data.delete(loc, log, err => { data.delete(loc, log, err => {
if (err && err.ObjNotFound) { if (err && err.is.ObjNotFound) {
log.info('batch delete: data location do not exist', { log.info('batch delete: data location do not exist', {
method: 'batchDelete', method: 'batchDelete',
location: loc, location: loc,

View File

@ -42,7 +42,7 @@ const services = {
// buckets to list. By returning an empty array, the // buckets to list. By returning an empty array, the
// getService API will just respond with the user info // getService API will just respond with the user info
// without listing any buckets. // without listing any buckets.
if (err && err.NoSuchBucket) { if (err && err.is.NoSuchBucket) {
log.trace('no buckets found'); log.trace('no buckets found');
// If we checked the old user bucket, that means we // If we checked the old user bucket, that means we
// already checked the new user bucket. If neither the // already checked the new user bucket. If neither the
@ -555,7 +555,7 @@ const services = {
// If the MPU was initiated, the mpu bucket should exist. // If the MPU was initiated, the mpu bucket should exist.
const mpuBucketName = `${constants.mpuBucketPrefix}${bucketName}`; const mpuBucketName = `${constants.mpuBucketPrefix}${bucketName}`;
metadata.getBucket(mpuBucketName, log, (err, mpuBucket) => { metadata.getBucket(mpuBucketName, log, (err, mpuBucket) => {
if (err && err.NoSuchBucket) { if (err && err.is.NoSuchBucket) {
log.debug('bucket not found in metadata', { error: err, log.debug('bucket not found in metadata', { error: err,
method: 'services.metadataValidateMultipart' }); method: 'services.metadataValidateMultipart' });
return cb(errors.NoSuchUpload); return cb(errors.NoSuchUpload);
@ -577,7 +577,7 @@ const services = {
metadata.getObjectMD(mpuBucket.getName(), mpuOverviewKey, metadata.getObjectMD(mpuBucket.getName(), mpuOverviewKey,
{}, log, (err, storedMetadata) => { {}, log, (err, storedMetadata) => {
if (err) { if (err) {
if (err.NoSuchKey) { if (err.is.NoSuchKey) {
return cb(errors.NoSuchUpload); return cb(errors.NoSuchUpload);
} }
log.error('error from metadata', { error: err }); log.error('error from metadata', { error: err });
@ -753,7 +753,7 @@ const services = {
assert.strictEqual(typeof bucketName, 'string'); assert.strictEqual(typeof bucketName, 'string');
const MPUBucketName = `${constants.mpuBucketPrefix}${bucketName}`; const MPUBucketName = `${constants.mpuBucketPrefix}${bucketName}`;
metadata.getBucket(MPUBucketName, log, (err, bucket) => { metadata.getBucket(MPUBucketName, log, (err, bucket) => {
if (err && err.NoSuchBucket) { if (err && err.is.NoSuchBucket) {
log.trace('no buckets found'); log.trace('no buckets found');
const creationDate = new Date().toJSON(); const creationDate = new Date().toJSON();
const mpuBucket = new BucketInfo(MPUBucketName, const mpuBucket = new BucketInfo(MPUBucketName,

View File

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

View File

@ -1,10 +1,10 @@
const assert = require('assert'); const assert = require('assert');
const { S3 } = require('aws-sdk'); const { S3 } = require('aws-sdk');
const { series } = require('async'); const { series } = require('async');
const { errors } = require('arsenal');
const getConfig = require('../support/config'); const getConfig = require('../support/config');
const BucketUtility = require('../../lib/utility/bucket-util'); const BucketUtility = require('../../lib/utility/bucket-util');
const { errors } = require('arsenal');
const bucket = 'source-bucket'; const bucket = 'source-bucket';
const replicationConfig = { const replicationConfig = {
@ -81,7 +81,7 @@ describe('aws-node-sdk test deleteBucketReplication', () => {
}), }),
next => deleteReplicationAndCheckResponse(bucket, next), next => deleteReplicationAndCheckResponse(bucket, next),
next => s3.getBucketReplication({ Bucket: bucket }, err => { next => s3.getBucketReplication({ Bucket: bucket }, err => {
assert(errors.ReplicationConfigurationNotFoundError[err.code]); assert(errors.ReplicationConfigurationNotFoundError.is[err.code]);
return next(); return next();
}), }),
], done)); ], done));

View File

@ -1,10 +1,10 @@
const assert = require('assert'); const assert = require('assert');
const { S3 } = require('aws-sdk'); const { S3 } = require('aws-sdk');
const { series } = require('async'); const { series } = require('async');
const { errors } = require('arsenal');
const getConfig = require('../support/config'); const getConfig = require('../support/config');
const BucketUtility = require('../../lib/utility/bucket-util'); const BucketUtility = require('../../lib/utility/bucket-util');
const { errors } = require('arsenal');
const bucket = 'source-bucket'; const bucket = 'source-bucket';
@ -45,7 +45,7 @@ describe('aws-node-sdk test getBucketReplication', () => {
it("should return 'ReplicationConfigurationNotFoundError' if bucket does " + it("should return 'ReplicationConfigurationNotFoundError' if bucket does " +
'not have a replication configuration', done => 'not have a replication configuration', done =>
s3.getBucketReplication({ Bucket: bucket }, err => { s3.getBucketReplication({ Bucket: bucket }, err => {
assert(errors.ReplicationConfigurationNotFoundError[err.code]); assert(errors.ReplicationConfigurationNotFoundError.is[err.code]);
return done(); return done();
})); }));

View File

@ -1,6 +1,5 @@
'use strict'; // eslint-disable-line strict 'use strict'; // eslint-disable-line strict
const assert = require('assert'); const assert = require('assert');
const { errors } = require('arsenal');
const DummyRequestLogger = require('../unit/helpers').DummyRequestLogger; const DummyRequestLogger = require('../unit/helpers').DummyRequestLogger;
const clientCheck const clientCheck
= require('../../lib/utilities/healthcheckHandler').clientCheck; = require('../../lib/utilities/healthcheckHandler').clientCheck;
@ -71,7 +70,7 @@ describe('Healthcheck response', () => {
const azureLocationNonExistContainerError = const azureLocationNonExistContainerError =
results[azureLocationNonExistContainer].error; results[azureLocationNonExistContainer].error;
if (err) { if (err) {
assert.strictEqual(err, errors.InternalError, assert(err.is.InternalError,
`got unexpected err in clientCheck: ${err}`); `got unexpected err in clientCheck: ${err}`);
assert(azureLocationNonExistContainerError.startsWith( assert(azureLocationNonExistContainerError.startsWith(
'The specified container is being deleted.')); 'The specified container is being deleted.'));

View File

@ -2,7 +2,7 @@ const assert = require('assert');
const async = require('async'); const async = require('async');
const AWS = require('aws-sdk'); const AWS = require('aws-sdk');
const { parseString } = require('xml2js'); const { parseString } = require('xml2js');
const { errors, models } = require('arsenal'); const { models } = require('arsenal');
const BucketInfo = models.BucketInfo; const BucketInfo = models.BucketInfo;
const { getRealAwsConfig } = const { getRealAwsConfig } =
@ -460,11 +460,13 @@ describe('Multipart Upload API with AWS Backend', function mpuTestSuite() {
abortMPU(uploadId, getAwsParams(objectKey), () => { abortMPU(uploadId, getAwsParams(objectKey), () => {
const listParams = getListParams(objectKey, uploadId); const listParams = getListParams(objectKey, uploadId);
listParts(authInfo, listParams, log, err => { listParts(authInfo, listParams, log, err => {
assert.deepStrictEqual(err, errors.ServiceUnavailable // TODO
.customizeDescription('Error returned from AWS: ' + assert.strictEqual(err.is.ServiceUnavailable, true);
'The specified upload does not exist. The upload ID ' + assert.strictEqual(err.description,
'may be invalid, or the upload may have been aborted ' + 'Error returned from AWS: ' +
'or completed.')); 'The specified upload does not exist. The upload ID ' +
'may be invalid, or the upload may have been aborted ' +
'or completed.');
done(); done();
}); });
}); });
@ -513,7 +515,7 @@ describe('Multipart Upload API with AWS Backend', function mpuTestSuite() {
const fakeKey = `key-${Date.now()}`; const fakeKey = `key-${Date.now()}`;
const delParams = getDeleteParams(fakeKey, fakeUploadId); const delParams = getDeleteParams(fakeKey, fakeUploadId);
multipartDelete(authInfo, delParams, log, err => { multipartDelete(authInfo, delParams, log, err => {
assert.equal(err, errors.NoSuchUpload, assert(err.is.NoSuchUpload,
`Error aborting MPU: ${err}`); `Error aborting MPU: ${err}`);
done(); done();
}); });
@ -639,7 +641,7 @@ describe('Multipart Upload API with AWS Backend', function mpuTestSuite() {
const compParams = getCompleteParams(objectKey, uploadId); const compParams = getCompleteParams(objectKey, uploadId);
compParams.post = errorBody; compParams.post = errorBody;
completeMultipartUpload(authInfo, compParams, log, err => { completeMultipartUpload(authInfo, compParams, log, err => {
assert.deepStrictEqual(err, errors.InvalidPart); assert(err.is.InvalidPart);
done(); done();
}); });
}); });
@ -661,7 +663,7 @@ describe('Multipart Upload API with AWS Backend', function mpuTestSuite() {
const compParams = getCompleteParams(objectKey, uploadId); const compParams = getCompleteParams(objectKey, uploadId);
compParams.post = errorBody; compParams.post = errorBody;
completeMultipartUpload(authInfo, compParams, log, err => { completeMultipartUpload(authInfo, compParams, log, err => {
assert.deepStrictEqual(err, errors.InvalidPartOrder); assert(err.is.InvalidPartOrder);
done(); done();
}); });
}); });
@ -687,7 +689,7 @@ describe('Multipart Upload API with AWS Backend', function mpuTestSuite() {
const compParams = getCompleteParams(objectKey, uploadId); const compParams = getCompleteParams(objectKey, uploadId);
compParams.post = errorBody; compParams.post = errorBody;
completeMultipartUpload(authInfo, compParams, log, err => { completeMultipartUpload(authInfo, compParams, log, err => {
assert.deepStrictEqual(err, errors.EntityTooSmall); assert(err.is.EntityTooSmall);
done(); done();
}); });
}); });
@ -825,7 +827,7 @@ describe('Multipart Upload API with AWS Backend', function mpuTestSuite() {
(uploadId, next) => { (uploadId, next) => {
const listParams = getListParams(objectKey, uploadId); const listParams = getListParams(objectKey, uploadId);
listParts(authInfo, listParams, log, err => { listParts(authInfo, listParams, log, err => {
assert(err.NoSuchUpload); assert(err.is.NoSuchUpload);
next(); next();
}); });
}, },

View File

@ -58,7 +58,7 @@ function put(bucketLoc, objLoc, requestHost, cb, errorDescription) {
resHeaders) => { resHeaders) => {
if (errorDescription) { if (errorDescription) {
assert.strictEqual(err.code, 400); assert.strictEqual(err.code, 400);
assert(err.InvalidArgument); assert(err.is.InvalidArgument);
assert(err.description.indexOf(errorDescription) > -1); assert(err.description.indexOf(errorDescription) > -1);
} else { } else {
assert.strictEqual(err, null, `Error putting object: ${err}`); assert.strictEqual(err, null, `Error putting object: ${err}`);

View File

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

View File

@ -99,7 +99,7 @@ errorDescription) {
(err, json) => { (err, json) => {
if (errorDescription) { if (errorDescription) {
assert.strictEqual(err.code, 400); assert.strictEqual(err.code, 400);
assert(err.InvalidArgument); assert(err.is.InvalidArgument);
assert(err.description.indexOf(errorDescription) > -1); assert(err.description.indexOf(errorDescription) > -1);
return cb(); return cb();
} }

View File

@ -37,7 +37,8 @@ describe('objectLockHelpers: validateHeaders', () => {
= validateHeaders(objLockDisabledBucketInfo, headers, log); = validateHeaders(objLockDisabledBucketInfo, headers, log);
const expectedError = errors.InvalidRequest.customizeDescription( const expectedError = errors.InvalidRequest.customizeDescription(
'Bucket is missing ObjectLockConfiguration'); 'Bucket is missing ObjectLockConfiguration');
assert.strictEqual(objectLockValidationError.InvalidRequest, true); assert.strictEqual(
objectLockValidationError.is.InvalidRequest, true);
assert.strictEqual(objectLockValidationError.description, assert.strictEqual(objectLockValidationError.description,
expectedError.description); expectedError.description);
}); });
@ -90,7 +91,8 @@ describe('objectLockHelpers: validateHeaders', () => {
const expectedError = errors.InvalidArgument.customizeDescription( const expectedError = errors.InvalidArgument.customizeDescription(
'x-amz-object-lock-retain-until-date and x-amz-object-lock-mode ' + 'x-amz-object-lock-retain-until-date and x-amz-object-lock-mode ' +
'must both be supplied'); 'must both be supplied');
assert.strictEqual(objectLockValidationError.InvalidArgument, true); assert.strictEqual(
objectLockValidationError.is.InvalidArgument, true);
assert.strictEqual(objectLockValidationError.description, assert.strictEqual(objectLockValidationError.description,
expectedError.description); expectedError.description);
}); });
@ -104,7 +106,8 @@ describe('objectLockHelpers: validateHeaders', () => {
const expectedError = errors.InvalidArgument.customizeDescription( const expectedError = errors.InvalidArgument.customizeDescription(
'x-amz-object-lock-retain-until-date and x-amz-object-lock-mode ' + 'x-amz-object-lock-retain-until-date and x-amz-object-lock-mode ' +
'must both be supplied'); 'must both be supplied');
assert.strictEqual(objectLockValidationError.InvalidArgument, true); assert.strictEqual(
objectLockValidationError.is.InvalidArgument, true);
assert.strictEqual(objectLockValidationError.description, assert.strictEqual(objectLockValidationError.description,
expectedError.description); expectedError.description);
}); });
@ -118,7 +121,8 @@ describe('objectLockHelpers: validateHeaders', () => {
'The retain until date must be in the future!'); 'The retain until date must be in the future!');
const objectLockValidationError const objectLockValidationError
= validateHeaders(bucketInfo, headers, log); = validateHeaders(bucketInfo, headers, log);
assert.strictEqual(objectLockValidationError.InvalidArgument, true); assert.strictEqual(
objectLockValidationError.is.InvalidArgument, true);
assert.strictEqual(objectLockValidationError.description, assert.strictEqual(objectLockValidationError.description,
expectedError.description); expectedError.description);
}); });
@ -131,7 +135,8 @@ describe('objectLockHelpers: validateHeaders', () => {
= validateHeaders(bucketInfo, headers, log); = validateHeaders(bucketInfo, headers, log);
const expectedError = errors.InvalidArgument.customizeDescription( const expectedError = errors.InvalidArgument.customizeDescription(
'Legal hold status must be one of "ON", "OFF"'); 'Legal hold status must be one of "ON", "OFF"');
assert.strictEqual(objectLockValidationError.InvalidArgument, true); assert.strictEqual(
objectLockValidationError.is.InvalidArgument, true);
assert.strictEqual(objectLockValidationError.description, assert.strictEqual(objectLockValidationError.description,
expectedError.description); expectedError.description);
}); });
@ -145,7 +150,8 @@ describe('objectLockHelpers: validateHeaders', () => {
= validateHeaders(bucketInfo, headers, log); = validateHeaders(bucketInfo, headers, log);
const expectedError = errors.InvalidArgument.customizeDescription( const expectedError = errors.InvalidArgument.customizeDescription(
'Unknown wormMode directive'); 'Unknown wormMode directive');
assert.strictEqual(objectLockValidationError.InvalidArgument, true); assert.strictEqual(
objectLockValidationError.is.InvalidArgument, true);
assert.strictEqual(objectLockValidationError.description, assert.strictEqual(objectLockValidationError.description,
expectedError.description); expectedError.description);
}); });
@ -207,7 +213,7 @@ describe('objectLockHelpers: validateObjectLockUpdate', () => {
}; };
const error = validateObjectLockUpdate(objMD, retentionInfo, false); const error = validateObjectLockUpdate(objMD, retentionInfo, false);
assert.deepStrictEqual(error, errors.AccessDenied); assert.strictEqual(error.is.AccessDenied, true);
}); });
it('should disallow COMPLIANCE => GOVERNANCE if retention is not expired', () => { it('should disallow COMPLIANCE => GOVERNANCE if retention is not expired', () => {
@ -222,7 +228,7 @@ describe('objectLockHelpers: validateObjectLockUpdate', () => {
}; };
const error = validateObjectLockUpdate(objMD, retentionInfo); const error = validateObjectLockUpdate(objMD, retentionInfo);
assert.deepStrictEqual(error, errors.AccessDenied); assert.strictEqual(error.is.AccessDenied, true);
}); });
it('should allow COMPLIANCE => GOVERNANCE if retention is expired', () => { it('should allow COMPLIANCE => GOVERNANCE if retention is expired', () => {
@ -267,7 +273,7 @@ describe('objectLockHelpers: validateObjectLockUpdate', () => {
}; };
const error = validateObjectLockUpdate(objMD, retentionInfo); const error = validateObjectLockUpdate(objMD, retentionInfo);
assert.deepStrictEqual(error, errors.AccessDenied); assert.strictEqual(error.is.AccessDenied, true);
}); });
it('should allow shortening retention period if in GOVERNANCE', () => { it('should allow shortening retention period if in GOVERNANCE', () => {

View File

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

View File

@ -2,7 +2,6 @@ const crypto = require('crypto');
const assert = require('assert'); const assert = require('assert');
const async = require('async'); const async = require('async');
const { parseString } = require('xml2js'); const { parseString } = require('xml2js');
const { errors } = require('arsenal');
const bucketDelete = require('../../../lib/api/bucketDelete'); const bucketDelete = require('../../../lib/api/bucketDelete');
const { bucketPut } = require('../../../lib/api/bucketPut'); const { bucketPut } = require('../../../lib/api/bucketPut');
@ -112,7 +111,7 @@ describe('bucketDelete API', () => {
objectPut(authInfo, testPutObjectRequest, undefined, log, err => { objectPut(authInfo, testPutObjectRequest, undefined, log, err => {
assert.strictEqual(err, null); assert.strictEqual(err, null);
bucketDelete(authInfo, testRequest, log, err => { bucketDelete(authInfo, testRequest, log, err => {
assert.deepStrictEqual(err, errors.BucketNotEmpty); assert(err.is.BucketNotEmpty);
metadata.getBucket(bucketName, log, (err, md) => { metadata.getBucket(bucketName, log, (err, md) => {
assert.strictEqual(md.getName(), bucketName); assert.strictEqual(md.getName(), bucketName);
metadata.listObject(usersBucket, metadata.listObject(usersBucket,
@ -146,7 +145,7 @@ describe('bucketDelete API', () => {
bucketPut(authInfo, testRequest, log, () => { bucketPut(authInfo, testRequest, log, () => {
bucketDelete(authInfo, testRequest, log, () => { bucketDelete(authInfo, testRequest, log, () => {
metadata.getBucket(bucketName, log, (err, md) => { metadata.getBucket(bucketName, log, (err, md) => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert(err.is.NoSuchBucket);
assert.strictEqual(md, undefined); assert.strictEqual(md, undefined);
metadata.listObject(usersBucket, { prefix: canonicalID }, metadata.listObject(usersBucket, { prefix: canonicalID },
log, (err, listResponse) => { log, (err, listResponse) => {
@ -169,7 +168,7 @@ describe('bucketDelete API', () => {
it('should prevent anonymous user delete bucket API access', done => { it('should prevent anonymous user delete bucket API access', done => {
const publicAuthInfo = makeAuthInfo(constants.publicId); const publicAuthInfo = makeAuthInfo(constants.publicId);
bucketDelete(publicAuthInfo, testRequest, log, err => { bucketDelete(publicAuthInfo, testRequest, log, err => {
assert.deepStrictEqual(err, errors.AccessDenied); assert(err.is.AccessDenied);
done(); done();
}); });
}); });

View File

@ -10,8 +10,6 @@ const objectPut = require('../../../lib/api/objectPut');
const { cleanup, DummyRequestLogger, makeAuthInfo } = require('../helpers'); const { cleanup, DummyRequestLogger, makeAuthInfo } = require('../helpers');
const DummyRequest = require('../DummyRequest'); const DummyRequest = require('../DummyRequest');
const { errors } = require('arsenal');
const authInfo = makeAuthInfo('accessKey1'); const authInfo = makeAuthInfo('accessKey1');
const bucketName = 'bucketname'; const bucketName = 'bucketname';
const delimiter = '/'; const delimiter = '/';
@ -199,7 +197,7 @@ describe('bucketGet API', () => {
const testGetRequest = Object.assign({ query: { 'max-keys': '-1' } }, const testGetRequest = Object.assign({ query: { 'max-keys': '-1' } },
baseGetRequest); baseGetRequest);
bucketGet(authInfo, testGetRequest, log, err => { bucketGet(authInfo, testGetRequest, log, err => {
assert.deepStrictEqual(err, errors.InvalidArgument); assert(err.is.InvalidArgument);
done(); done();
}); });
}); });

View File

@ -28,7 +28,7 @@ describe('getBucketLifecycle API', () => {
'bucket has no lifecycle', done => { 'bucket has no lifecycle', done => {
const lifecycleRequest = getLifecycleRequest(bucketName); const lifecycleRequest = getLifecycleRequest(bucketName);
bucketGetLifecycle(authInfo, lifecycleRequest, log, err => { bucketGetLifecycle(authInfo, lifecycleRequest, log, err => {
assert.strictEqual(err.NoSuchLifecycleConfiguration, true); assert.strictEqual(err.is.NoSuchLifecycleConfiguration, true);
done(); done();
}); });
}); });

View File

@ -74,7 +74,7 @@ describe('bucketGetObjectLock API', () => {
'object lock is not enabled on the bucket', done => { 'object lock is not enabled on the bucket', done => {
const objectLockRequest = getObjectLockConfigRequest(bucketName); const objectLockRequest = getObjectLockConfigRequest(bucketName);
bucketGetObjectLock(authInfo, objectLockRequest, log, err => { bucketGetObjectLock(authInfo, objectLockRequest, log, err => {
assert.strictEqual(err.ObjectLockConfigurationNotFoundError, true); assert.strictEqual(err.is.ObjectLockConfigurationNotFoundError, true);
done(); done();
}); });
}); });

View File

@ -44,7 +44,7 @@ describe('getBucketPolicy API', () => {
it('should return NoSuchBucketPolicy error if ' + it('should return NoSuchBucketPolicy error if ' +
'bucket has no policy', done => { 'bucket has no policy', done => {
bucketGetPolicy(authInfo, testBasicRequest, log, err => { bucketGetPolicy(authInfo, testBasicRequest, log, err => {
assert.strictEqual(err.NoSuchBucketPolicy, true); assert.strictEqual(err.is.NoSuchBucketPolicy, true);
done(); done();
}); });
}); });

View File

@ -1,5 +1,4 @@
const assert = require('assert'); const assert = require('assert');
const { errors } = require('arsenal');
const bucketHead = require('../../../lib/api/bucketHead'); const bucketHead = require('../../../lib/api/bucketHead');
const { bucketPut } = require('../../../lib/api/bucketPut'); const { bucketPut } = require('../../../lib/api/bucketPut');
@ -22,7 +21,7 @@ describe('bucketHead API', () => {
it('should return an error if the bucket does not exist', done => { it('should return an error if the bucket does not exist', done => {
bucketHead(authInfo, testRequest, log, err => { bucketHead(authInfo, testRequest, log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -31,7 +30,7 @@ describe('bucketHead API', () => {
const otherAuthInfo = makeAuthInfo('accessKey2'); const otherAuthInfo = makeAuthInfo('accessKey2');
bucketPut(otherAuthInfo, testRequest, log, () => { bucketPut(otherAuthInfo, testRequest, log, () => {
bucketHead(authInfo, testRequest, log, err => { bucketHead(authInfo, testRequest, log, err => {
assert.deepStrictEqual(err, errors.AccessDenied); assert.strictEqual(err.is.AccessDenied, true);
done(); done();
}); });
}); });

View File

@ -1,5 +1,4 @@
const assert = require('assert'); const assert = require('assert');
const { errors } = require('arsenal');
const { checkLocationConstraint } = require('../../../lib/api/bucketPut'); const { checkLocationConstraint } = require('../../../lib/api/bucketPut');
const { bucketPut } = require('../../../lib/api/bucketPut'); const { bucketPut } = require('../../../lib/api/bucketPut');
@ -83,8 +82,8 @@ describe('checkLocationConstraint function', () => {
if (testCheck.isError) { if (testCheck.isError) {
assert.notEqual(checkLocation.error, null, assert.notEqual(checkLocation.error, null,
'Expected failure but got success'); 'Expected failure but got success');
assert.strictEqual(checkLocation.error. assert.strictEqual(
InvalidLocationConstraint, true); checkLocation.error.is.InvalidLocationConstraint, true);
} else { } else {
assert.ifError(checkLocation.error); assert.ifError(checkLocation.error);
assert.strictEqual(checkLocation.locationConstraint, assert.strictEqual(checkLocation.locationConstraint,
@ -105,7 +104,7 @@ describe('bucketPut API', () => {
bucketPut(authInfo, testRequest, log, () => { bucketPut(authInfo, testRequest, log, () => {
bucketPut(otherAuthInfo, testRequest, bucketPut(otherAuthInfo, testRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.BucketAlreadyExists); assert.strictEqual(err.is.BucketAlreadyExists, true);
done(); done();
}); });
}); });
@ -188,9 +187,9 @@ describe('bucketPut API', () => {
post: '', post: '',
}; };
bucketPut(authInfo, testRequest, log, err => { bucketPut(authInfo, testRequest, log, err => {
assert.deepStrictEqual(err, errors.InvalidArgument); assert.strictEqual(err.is.InvalidArgument, true);
metadata.getBucket(bucketName, log, err => { metadata.getBucket(bucketName, log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -209,9 +208,9 @@ describe('bucketPut API', () => {
post: '', post: '',
}; };
bucketPut(authInfo, testRequest, log, err => { bucketPut(authInfo, testRequest, log, err => {
assert.deepStrictEqual(err, errors.InvalidArgument); assert.strictEqual(err.is.InvalidArgument, true);
metadata.getBucket(bucketName, log, err => { metadata.getBucket(bucketName, log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -231,9 +230,9 @@ describe('bucketPut API', () => {
post: '', post: '',
}; };
bucketPut(authInfo, testRequest, log, err => { bucketPut(authInfo, testRequest, log, err => {
assert.deepStrictEqual(err, errors.UnresolvableGrantByEmailAddress); assert.strictEqual(err.is.UnresolvableGrantByEmailAddress, true);
metadata.getBucket(bucketName, log, err => { metadata.getBucket(bucketName, log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -309,7 +308,7 @@ describe('bucketPut API', () => {
it('should prevent anonymous user from accessing putBucket API', done => { it('should prevent anonymous user from accessing putBucket API', done => {
const publicAuthInfo = makeAuthInfo(constants.publicId); const publicAuthInfo = makeAuthInfo(constants.publicId);
bucketPut(publicAuthInfo, testRequest, log, err => { bucketPut(publicAuthInfo, testRequest, log, err => {
assert.deepStrictEqual(err, errors.AccessDenied); assert.strictEqual(err.is.AccessDenied, true);
}); });
done(); done();
}); });
@ -367,11 +366,10 @@ describe('bucketPut API', () => {
it('should return error if location constraint config is not updated', it('should return error if location constraint config is not updated',
done => bucketPut(authInfo, req, log, err => { done => bucketPut(authInfo, req, log, err => {
const expectedError = errors.InvalidLocationConstraint; assert.strictEqual(err.is.InvalidLocationConstraint, true);
expectedError.description = 'value of the location you are ' + assert.strictEqual(err.description, 'value of the location you are ' +
`attempting to set - ${newLCKey} - is not listed in the ` + `attempting to set - ${newLCKey} - is not listed in the ` +
'locationConstraint config'; 'locationConstraint config');
assert.deepStrictEqual(err, expectedError);
done(); done();
})); }));

View File

@ -1,5 +1,4 @@
const assert = require('assert'); const assert = require('assert');
const { errors } = require('arsenal');
const aclUtils = require('../../../lib/utilities/aclUtils'); const aclUtils = require('../../../lib/utilities/aclUtils');
const { bucketPut } = require('../../../lib/api/bucketPut'); const { bucketPut } = require('../../../lib/api/bucketPut');
@ -75,7 +74,7 @@ describe('putBucketACL API', () => {
}; };
bucketPutACL(authInfo, testACLRequest, log, err => { bucketPutACL(authInfo, testACLRequest, log, err => {
assert.deepStrictEqual(err, errors.InvalidArgument); assert.strictEqual(err.is.InvalidArgument, true);
done(); done();
}); });
}); });
@ -273,7 +272,7 @@ describe('putBucketACL API', () => {
query: { acl: '' }, query: { acl: '' },
}; };
return bucketPutACL(authInfo, testACLRequest, log, err => { return bucketPutACL(authInfo, testACLRequest, log, err => {
assert.deepStrictEqual(err, errors.InvalidArgument); assert.strictEqual(err.is.InvalidArgument, true);
done(); done();
}); });
}); });
@ -295,7 +294,7 @@ describe('putBucketACL API', () => {
}; };
bucketPutACL(authInfo, testACLRequest, log, err => { bucketPutACL(authInfo, testACLRequest, log, err => {
assert.deepStrictEqual(err, errors.UnresolvableGrantByEmailAddress); assert.strictEqual(err.is.UnresolvableGrantByEmailAddress, true);
done(); done();
}); });
}); });
@ -421,7 +420,7 @@ describe('putBucketACL API', () => {
}; };
bucketPutACL(authInfo, testACLRequest, log, err => { bucketPutACL(authInfo, testACLRequest, log, err => {
assert.deepStrictEqual(err, errors.MalformedACLError); assert.strictEqual(err.is.MalformedACLError, true);
done(); done();
}); });
}); });
@ -464,7 +463,7 @@ describe('putBucketACL API', () => {
}; };
bucketPutACL(authInfo, testACLRequest, log, err => { bucketPutACL(authInfo, testACLRequest, log, err => {
assert.deepStrictEqual(err, errors.MalformedACLError); assert.strictEqual(err.is.MalformedACLError, true);
done(); done();
}); });
}); });
@ -496,7 +495,7 @@ describe('putBucketACL API', () => {
}; };
return bucketPutACL(authInfo, testACLRequest, log, err => { return bucketPutACL(authInfo, testACLRequest, log, err => {
assert.deepStrictEqual(err, errors.InvalidArgument); assert.strictEqual(err.is.InvalidArgument, true);
done(); done();
}); });
}); });
@ -527,7 +526,7 @@ describe('putBucketACL API', () => {
query: { acl: '' }, query: { acl: '' },
}; };
bucketPutACL(authInfo, testACLRequest, log, err => { bucketPutACL(authInfo, testACLRequest, log, err => {
assert.deepStrictEqual(err, errors.UnresolvableGrantByEmailAddress); assert.strictEqual(err.is.UnresolvableGrantByEmailAddress, true);
done(); done();
}); });
}); });
@ -563,7 +562,7 @@ describe('putBucketACL API', () => {
}; };
bucketPutACL(authInfo, testACLRequest, log, err => { bucketPutACL(authInfo, testACLRequest, log, err => {
assert.deepStrictEqual(err, errors.MalformedACLError); assert.strictEqual(err.is.MalformedACLError, true);
done(); done();
}); });
}); });
@ -608,7 +607,7 @@ describe('putBucketACL API', () => {
}; };
bucketPutACL(authInfo, testACLRequest, log, err => { bucketPutACL(authInfo, testACLRequest, log, err => {
assert.deepStrictEqual(err, errors.MalformedACLError); assert.strictEqual(err.is.MalformedACLError, true);
done(); done();
}); });
}); });
@ -643,7 +642,7 @@ describe('putBucketACL API', () => {
}; };
bucketPutACL(authInfo, testACLRequest, log, err => { bucketPutACL(authInfo, testACLRequest, log, err => {
assert.deepStrictEqual(err, errors.MalformedXML); assert.strictEqual(err.is.MalformedXML, true);
done(); done();
}); });
}); });
@ -677,7 +676,7 @@ describe('putBucketACL API', () => {
}; };
bucketPutACL(authInfo, testACLRequest, log, err => { bucketPutACL(authInfo, testACLRequest, log, err => {
assert.deepStrictEqual(err, errors.InvalidArgument); assert.strictEqual(err.is.InvalidArgument, true);
done(); done();
}); });
}); });
@ -698,7 +697,7 @@ describe('putBucketACL API', () => {
}; };
bucketPutACL(authInfo, testACLRequest, log, err => { bucketPutACL(authInfo, testACLRequest, log, err => {
assert.deepStrictEqual(err, errors.InvalidArgument); assert.strictEqual(err.is.InvalidArgument, true);
done(); done();
}); });
}); });

View File

@ -129,7 +129,7 @@ describe('PUT bucket cors :: helper validation functions ', () => {
`<ID>${testValue}</ID>`); `<ID>${testValue}</ID>`);
parseCorsXml(xml, log, err => { parseCorsXml(xml, log, err => {
assert(err, 'Expected error but found none'); assert(err, 'Expected error but found none');
assert.deepStrictEqual(err, errors.MalformedXML); assert.strictEqual(err.is.MalformedXML, true);
return done(); return done();
}); });
}); });
@ -175,7 +175,7 @@ describe('PUT bucket cors :: helper validation functions ', () => {
`<MaxAgeSeconds>${testValue}</MaxAgeSeconds>`); `<MaxAgeSeconds>${testValue}</MaxAgeSeconds>`);
parseCorsXml(xml, log, err => { parseCorsXml(xml, log, err => {
assert(err, 'Expected error but found none'); assert(err, 'Expected error but found none');
assert.deepStrictEqual(err, errors.MalformedXML); assert.strictEqual(err.is.MalformedXML, true);
return done(); return done();
}); });
}); });

View File

@ -25,7 +25,7 @@ describe('bucketPutEncryption API', () => {
describe('test invalid sse configs', () => { describe('test invalid sse configs', () => {
it('should reject an empty config', done => { it('should reject an empty config', done => {
bucketPutEncryption(authInfo, templateRequest(bucketName, { post: '' }), log, err => { bucketPutEncryption(authInfo, templateRequest(bucketName, { post: '' }), log, err => {
assert.strictEqual(err.MalformedXML, true); assert.strictEqual(err.is.MalformedXML, true);
done(); done();
}); });
}); });
@ -36,7 +36,7 @@ describe('bucketPutEncryption API', () => {
<ServerSideEncryptionConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <ServerSideEncryptionConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
</ServerSideEncryptionConfiguration>`, </ServerSideEncryptionConfiguration>`,
}), log, err => { }), log, err => {
assert.strictEqual(err.MalformedXML, true); assert.strictEqual(err.is.MalformedXML, true);
done(); done();
}); });
}); });
@ -48,7 +48,7 @@ describe('bucketPutEncryption API', () => {
<Rule></Rule> <Rule></Rule>
</ServerSideEncryptionConfiguration>`, </ServerSideEncryptionConfiguration>`,
}), log, err => { }), log, err => {
assert.strictEqual(err.MalformedXML, true); assert.strictEqual(err.is.MalformedXML, true);
done(); done();
}); });
}); });
@ -56,7 +56,7 @@ describe('bucketPutEncryption API', () => {
it('should reject a config with no SSEAlgorithm', done => { it('should reject a config with no SSEAlgorithm', done => {
const post = templateSSEConfig({}); const post = templateSSEConfig({});
bucketPutEncryption(authInfo, templateRequest(bucketName, { post }), log, err => { bucketPutEncryption(authInfo, templateRequest(bucketName, { post }), log, err => {
assert.strictEqual(err.MalformedXML, true); assert.strictEqual(err.is.MalformedXML, true);
done(); done();
}); });
}); });
@ -64,7 +64,7 @@ describe('bucketPutEncryption API', () => {
it('should reject a config with an invalid SSEAlgorithm', done => { it('should reject a config with an invalid SSEAlgorithm', done => {
const post = templateSSEConfig({ algorithm: 'InvalidAlgo' }); const post = templateSSEConfig({ algorithm: 'InvalidAlgo' });
bucketPutEncryption(authInfo, templateRequest(bucketName, { post }), log, err => { bucketPutEncryption(authInfo, templateRequest(bucketName, { post }), log, err => {
assert.strictEqual(err.MalformedXML, true); assert.strictEqual(err.is.MalformedXML, true);
done(); done();
}); });
}); });
@ -72,7 +72,7 @@ describe('bucketPutEncryption API', () => {
it('should reject a config with SSEAlgorithm == AES256 and a provided KMSMasterKeyID', done => { it('should reject a config with SSEAlgorithm == AES256 and a provided KMSMasterKeyID', done => {
const post = templateSSEConfig({ algorithm: 'AES256', keyId: '12345' }); const post = templateSSEConfig({ algorithm: 'AES256', keyId: '12345' });
bucketPutEncryption(authInfo, templateRequest(bucketName, { post }), log, err => { bucketPutEncryption(authInfo, templateRequest(bucketName, { post }), log, err => {
assert.strictEqual(err.InvalidArgument, true); assert.strictEqual(err.is.InvalidArgument, true);
done(); done();
}); });
}); });

View File

@ -48,7 +48,7 @@ describe('putBucketObjectLock API', () => {
it('should return InvalidBucketState error', done => { it('should return InvalidBucketState error', done => {
bucketPutObjectLock(authInfo, putObjLockRequest, log, err => { bucketPutObjectLock(authInfo, putObjLockRequest, log, err => {
assert.strictEqual(err.InvalidBucketState, true); assert.strictEqual(err.is.InvalidBucketState, true);
done(); done();
}); });
}); });

View File

@ -70,7 +70,7 @@ describe('putBucketPolicy API', () => {
expectedBucketPolicy.Statement[0].Resource = 'arn:aws::s3:::badname'; expectedBucketPolicy.Statement[0].Resource = 'arn:aws::s3:::badname';
bucketPutPolicy(authInfo, getPolicyRequest(expectedBucketPolicy), bucketPutPolicy(authInfo, getPolicyRequest(expectedBucketPolicy),
log, err => { log, err => {
assert.strictEqual(err.MalformedPolicy, true); assert.strictEqual(err.is.MalformedPolicy, true);
assert.strictEqual(err.description, 'Policy has invalid resource'); assert.strictEqual(err.description, 'Policy has invalid resource');
return done(); return done();
}); });
@ -81,7 +81,7 @@ describe('putBucketPolicy API', () => {
{ StringEquals: { 's3:x-amz-acl': ['public-read'] } }; { StringEquals: { 's3:x-amz-acl': ['public-read'] } };
bucketPutPolicy(authInfo, getPolicyRequest(expectedBucketPolicy), log, bucketPutPolicy(authInfo, getPolicyRequest(expectedBucketPolicy), log,
err => { err => {
assert.strictEqual(err.NotImplemented, true); assert.strictEqual(err.is.NotImplemented, true);
done(); done();
}); });
}); });
@ -90,7 +90,7 @@ describe('putBucketPolicy API', () => {
expectedBucketPolicy.Statement[0].Principal = { Service: ['test.com'] }; expectedBucketPolicy.Statement[0].Principal = { Service: ['test.com'] };
bucketPutPolicy(authInfo, getPolicyRequest(expectedBucketPolicy), log, bucketPutPolicy(authInfo, getPolicyRequest(expectedBucketPolicy), log,
err => { err => {
assert.strictEqual(err.NotImplemented, true); assert.strictEqual(err.is.NotImplemented, true);
done(); done();
}); });
}); });
@ -100,7 +100,7 @@ describe('putBucketPolicy API', () => {
{ Federated: 'www.test.com' }; { Federated: 'www.test.com' };
bucketPutPolicy(authInfo, getPolicyRequest(expectedBucketPolicy), log, bucketPutPolicy(authInfo, getPolicyRequest(expectedBucketPolicy), log,
err => { err => {
assert.strictEqual(err.NotImplemented, true); assert.strictEqual(err.is.NotImplemented, true);
done(); done();
}); });
}); });

View File

@ -13,7 +13,7 @@ function checkError(xml, expectedErr, cb) {
if (expectedErr === null) { if (expectedErr === null) {
assert.strictEqual(err, null, `expected no error but got '${err}'`); assert.strictEqual(err, null, `expected no error but got '${err}'`);
} else { } else {
assert(err[expectedErr], 'incorrect error response: should be ' + assert(err.is[expectedErr], 'incorrect error response: should be ' +
`'Error: ${expectedErr}' but got '${err}'`); `'Error: ${expectedErr}' but got '${err}'`);
} }
return cb(); return cb();

View File

@ -1,6 +1,5 @@
const crypto = require('crypto'); const crypto = require('crypto');
const assert = require('assert'); const assert = require('assert');
const { errors } = require('arsenal');
const BucketInfo = require('arsenal').models.BucketInfo; const BucketInfo = require('arsenal').models.BucketInfo;
const bucketGet = require('../../../lib/api/bucketGet'); const bucketGet = require('../../../lib/api/bucketGet');
@ -96,7 +95,7 @@ function confirmDeleted(done) {
process.nextTick(() => { process.nextTick(() => {
process.nextTick(() => { process.nextTick(() => {
metadata.getBucket(bucketName, log, err => { metadata.getBucket(bucketName, log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
return checkBucketListing(authInfo, bucketName, 0, done); return checkBucketListing(authInfo, bucketName, 0, done);
}); });
}); });
@ -138,7 +137,7 @@ describe('deleted flag bucket handling', () => {
'different account sends put bucket request for bucket with ' + 'different account sends put bucket request for bucket with ' +
'deleted flag', done => { 'deleted flag', done => {
bucketPut(otherAccountAuthInfo, baseTestRequest, log, err => { bucketPut(otherAccountAuthInfo, baseTestRequest, log, err => {
assert.deepStrictEqual(err, errors.BucketAlreadyExists); assert.strictEqual(err.is.BucketAlreadyExists, true);
metadata.getBucket(bucketName, log, (err, data) => { metadata.getBucket(bucketName, log, (err, data) => {
assert.strictEqual(data._transient, false); assert.strictEqual(data._transient, false);
assert.strictEqual(data._deleted, true); assert.strictEqual(data._deleted, true);
@ -193,7 +192,7 @@ describe('deleted flag bucket handling', () => {
'x-amz-acl': 'public-read' }, 'headers', 'x-amz-acl': 'public-read' }, 'headers',
baseTestRequest, baseTestRequest.headers); baseTestRequest, baseTestRequest.headers);
bucketPutACL(otherAccountAuthInfo, putACLRequest, log, err => { bucketPutACL(otherAccountAuthInfo, putACLRequest, log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
metadata.getBucket(bucketName, log, (err, data) => { metadata.getBucket(bucketName, log, (err, data) => {
assert.strictEqual(data._deleted, true); assert.strictEqual(data._deleted, true);
assert.strictEqual(data._transient, false); assert.strictEqual(data._transient, false);
@ -212,7 +211,7 @@ describe('deleted flag bucket handling', () => {
baseTestRequest, baseTestRequest.headers); baseTestRequest, baseTestRequest.headers);
const unauthorizedAccount = makeAuthInfo('keepMeOut'); const unauthorizedAccount = makeAuthInfo('keepMeOut');
bucketPutACL(unauthorizedAccount, putACLRequest, log, err => { bucketPutACL(unauthorizedAccount, putACLRequest, log, err => {
assert.deepStrictEqual(err, errors.AccessDenied); assert.strictEqual(err.is.AccessDenied, true);
metadata.getBucket(bucketName, log, (err, data) => { metadata.getBucket(bucketName, log, (err, data) => {
assert.strictEqual(data._deleted, true); assert.strictEqual(data._deleted, true);
assert.strictEqual(data._transient, false); assert.strictEqual(data._transient, false);
@ -266,7 +265,7 @@ describe('deleted flag bucket handling', () => {
const postBody = Buffer.from('I am a body', 'utf8'); const postBody = Buffer.from('I am a body', 'utf8');
const putObjRequest = new DummyRequest(setUpRequest, postBody); const putObjRequest = new DummyRequest(setUpRequest, postBody);
objectPut(otherAccountAuthInfo, putObjRequest, undefined, log, err => { objectPut(otherAccountAuthInfo, putObjRequest, undefined, log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -314,7 +313,7 @@ describe('deleted flag bucket handling', () => {
initiateRequest.objectKey = 'objectName'; initiateRequest.objectKey = 'objectName';
initiateMultipartUpload(otherAccountAuthInfo, initiateRequest, log, initiateMultipartUpload(otherAccountAuthInfo, initiateRequest, log,
err => { err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -331,7 +330,7 @@ describe('deleted flag bucket handling', () => {
'authorized', done => { 'authorized', done => {
bucketDelete(otherAccountAuthInfo, baseTestRequest, bucketDelete(otherAccountAuthInfo, baseTestRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.AccessDenied); assert.strictEqual(err.is.AccessDenied, true);
done(); done();
}); });
}); });
@ -340,7 +339,7 @@ describe('deleted flag bucket handling', () => {
'NoSuchBucket error and complete deletion', done => { 'NoSuchBucket error and complete deletion', done => {
bucketDeleteWebsite(authInfo, baseTestRequest, bucketDeleteWebsite(authInfo, baseTestRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
confirmDeleted(done); confirmDeleted(done);
}); });
}); });
@ -349,7 +348,7 @@ describe('deleted flag bucket handling', () => {
'NoSuchBucket error and complete deletion', done => { 'NoSuchBucket error and complete deletion', done => {
bucketGet(authInfo, baseTestRequest, bucketGet(authInfo, baseTestRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
confirmDeleted(done); confirmDeleted(done);
}); });
}); });
@ -358,7 +357,7 @@ describe('deleted flag bucket handling', () => {
'NoSuchBucket error and complete deletion', done => { 'NoSuchBucket error and complete deletion', done => {
bucketGetACL(authInfo, baseTestRequest, bucketGetACL(authInfo, baseTestRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
confirmDeleted(done); confirmDeleted(done);
}); });
}); });
@ -367,7 +366,7 @@ describe('deleted flag bucket handling', () => {
'NoSuchBucket error and complete deletion', done => { 'NoSuchBucket error and complete deletion', done => {
bucketGetCors(authInfo, baseTestRequest, bucketGetCors(authInfo, baseTestRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
confirmDeleted(done); confirmDeleted(done);
}); });
}); });
@ -383,7 +382,7 @@ describe('deleted flag bucket handling', () => {
bucketPutCorsRequest.headers['content-md5'] = crypto.createHash('md5') bucketPutCorsRequest.headers['content-md5'] = crypto.createHash('md5')
.update(bucketPutCorsRequest.post, 'utf8').digest('base64'); .update(bucketPutCorsRequest.post, 'utf8').digest('base64');
bucketPutCors(authInfo, bucketPutCorsRequest, log, err => { bucketPutCors(authInfo, bucketPutCorsRequest, log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
confirmDeleted(done); confirmDeleted(done);
}); });
}); });
@ -391,7 +390,7 @@ describe('deleted flag bucket handling', () => {
it('bucketDeleteCors request on bucket with delete flag should return ' + it('bucketDeleteCors request on bucket with delete flag should return ' +
'NoSuchBucket error and complete deletion', done => { 'NoSuchBucket error and complete deletion', done => {
bucketDeleteCors(authInfo, baseTestRequest, log, err => { bucketDeleteCors(authInfo, baseTestRequest, log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
confirmDeleted(done); confirmDeleted(done);
}); });
}); });
@ -400,7 +399,7 @@ describe('deleted flag bucket handling', () => {
'NoSuchBucket error and complete deletion', done => { 'NoSuchBucket error and complete deletion', done => {
bucketGetWebsite(authInfo, baseTestRequest, bucketGetWebsite(authInfo, baseTestRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
confirmDeleted(done); confirmDeleted(done);
}); });
}); });
@ -414,7 +413,7 @@ describe('deleted flag bucket handling', () => {
'</WebsiteConfiguration>'; '</WebsiteConfiguration>';
bucketPutWebsite(authInfo, bucketPutWebsiteRequest, bucketPutWebsite(authInfo, bucketPutWebsiteRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
confirmDeleted(done); confirmDeleted(done);
}); });
}); });
@ -423,7 +422,7 @@ describe('deleted flag bucket handling', () => {
'NoSuchBucket error and complete deletion', done => { 'NoSuchBucket error and complete deletion', done => {
bucketHead(authInfo, baseTestRequest, bucketHead(authInfo, baseTestRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
confirmDeleted(done); confirmDeleted(done);
}); });
}); });
@ -438,13 +437,13 @@ describe('deleted flag bucket handling', () => {
if (extraArgNeeded) { if (extraArgNeeded) {
return apiAction(authInfo, mpuRequest, undefined, return apiAction(authInfo, mpuRequest, undefined,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchUpload); assert.strictEqual(err.is.NoSuchUpload, true);
return done(); return done();
}); });
} }
return apiAction(authInfo, mpuRequest, return apiAction(authInfo, mpuRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchUpload); assert.strictEqual(err.is.NoSuchUpload, true);
return done(); return done();
}); });
} }
@ -495,7 +494,7 @@ describe('deleted flag bucket handling', () => {
listRequest.query = {}; listRequest.query = {};
listMultipartUploads(authInfo, listRequest, listMultipartUploads(authInfo, listRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -505,7 +504,7 @@ describe('deleted flag bucket handling', () => {
done => { done => {
objectGet(authInfo, baseTestRequest, false, objectGet(authInfo, baseTestRequest, false,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
confirmDeleted(done); confirmDeleted(done);
}); });
}); });
@ -514,7 +513,7 @@ describe('deleted flag bucket handling', () => {
'NoSuchBucket error and complete deletion', done => { 'NoSuchBucket error and complete deletion', done => {
objectGetACL(authInfo, baseTestRequest, objectGetACL(authInfo, baseTestRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
confirmDeleted(done); confirmDeleted(done);
}); });
}); });
@ -523,7 +522,7 @@ describe('deleted flag bucket handling', () => {
'NoSuchBucket error and complete deletion', done => { 'NoSuchBucket error and complete deletion', done => {
objectHead(authInfo, baseTestRequest, objectHead(authInfo, baseTestRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
confirmDeleted(done); confirmDeleted(done);
}); });
}); });
@ -532,7 +531,7 @@ describe('deleted flag bucket handling', () => {
'NoSuchBucket error and complete deletion', done => { 'NoSuchBucket error and complete deletion', done => {
objectPutACL(authInfo, baseTestRequest, objectPutACL(authInfo, baseTestRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
confirmDeleted(done); confirmDeleted(done);
}); });
}); });
@ -541,7 +540,7 @@ describe('deleted flag bucket handling', () => {
'NoSuchBucket error', done => { 'NoSuchBucket error', done => {
objectDelete(authInfo, baseTestRequest, objectDelete(authInfo, baseTestRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
confirmDeleted(done); confirmDeleted(done);
}); });
}); });

View File

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

View File

@ -168,7 +168,7 @@ describe('Multipart Upload API', () => {
'no destination bucket', done => { 'no destination bucket', done => {
initiateMultipartUpload(authInfo, initiateRequest, initiateMultipartUpload(authInfo, initiateRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -315,7 +315,7 @@ describe('Multipart Upload API', () => {
}, postBody); }, postBody);
objectPutPart(authInfo, partRequest, undefined, log, objectPutPart(authInfo, partRequest, undefined, log,
(err, result) => { (err, result) => {
assert.deepStrictEqual(err, errors.TooManyParts); assert.strictEqual(err.is.TooManyParts, true);
assert.strictEqual(result, undefined); assert.strictEqual(result, undefined);
done(); done();
}); });
@ -351,7 +351,7 @@ describe('Multipart Upload API', () => {
}, postBody); }, postBody);
objectPutPart(authInfo, partRequest, undefined, log, objectPutPart(authInfo, partRequest, undefined, log,
(err, result) => { (err, result) => {
assert.deepStrictEqual(err, errors.InvalidArgument); assert.strictEqual(err.is.InvalidArgument, true);
assert.strictEqual(result, undefined); assert.strictEqual(result, undefined);
done(); done();
}); });
@ -394,7 +394,7 @@ describe('Multipart Upload API', () => {
}, postBody); }, postBody);
objectPutPart(authInfo, partRequest, undefined, objectPutPart(authInfo, partRequest, undefined,
log, (err, result) => { log, (err, result) => {
assert.deepStrictEqual(err, errors.EntityTooLarge); assert.strictEqual(err.is.EntityTooLarge, true);
assert.strictEqual(result, undefined); assert.strictEqual(result, undefined);
done(); done();
}); });
@ -691,7 +691,7 @@ describe('Multipart Upload API', () => {
}; };
completeMultipartUpload(authInfo, completeMultipartUpload(authInfo,
completeRequest, log, err => { completeRequest, log, err => {
assert.deepStrictEqual(err, errors.MalformedXML); assert.strictEqual(err.is.MalformedXML, true);
assert.strictEqual(metadata.keyMaps.get(mpuBucket).size, assert.strictEqual(metadata.keyMaps.get(mpuBucket).size,
2); 2);
done(); done();
@ -745,7 +745,7 @@ describe('Multipart Upload API', () => {
calculatedHash, calculatedHash,
}; };
completeMultipartUpload(authInfo, completeRequest, log, err => { completeMultipartUpload(authInfo, completeRequest, log, err => {
assert.deepStrictEqual(err, errors.MalformedXML); assert.strictEqual(err.is.MalformedXML, true);
done(); done();
}); });
}); });
@ -818,8 +818,7 @@ describe('Multipart Upload API', () => {
}; };
completeMultipartUpload(authInfo, completeMultipartUpload(authInfo,
completeRequest, log, err => { completeRequest, log, err => {
assert.deepStrictEqual(err, assert.strictEqual(err.is.InvalidPartOrder, true);
errors.InvalidPartOrder);
assert.strictEqual(metadata.keyMaps assert.strictEqual(metadata.keyMaps
.get(mpuBucket).size, 3); .get(mpuBucket).size, 3);
done(); done();
@ -876,8 +875,7 @@ describe('Multipart Upload API', () => {
calculatedHash, calculatedHash,
}; };
completeMultipartUpload(authInfo, completeRequest, log, err => { completeMultipartUpload(authInfo, completeRequest, log, err => {
assert.deepStrictEqual(err, assert.strictEqual(err.is.InvalidPart, true);
errors.InvalidPart);
assert.strictEqual(metadata.keyMaps.get(mpuBucket).size, 2); assert.strictEqual(metadata.keyMaps.get(mpuBucket).size, 2);
done(); done();
}); });
@ -950,7 +948,7 @@ describe('Multipart Upload API', () => {
assert.strictEqual(metadata.keyMaps.get(mpuBucket).size, 3); assert.strictEqual(metadata.keyMaps.get(mpuBucket).size, 3);
completeMultipartUpload(authInfo, completeMultipartUpload(authInfo,
completeRequest, log, err => { completeRequest, log, err => {
assert.deepStrictEqual(err, errors.InvalidPart); assert.strictEqual(err.is.InvalidPart, true);
done(); done();
}); });
}); });
@ -1032,8 +1030,7 @@ describe('Multipart Upload API', () => {
assert.strictEqual(metadata.keyMaps.get(mpuBucket).size, 3); assert.strictEqual(metadata.keyMaps.get(mpuBucket).size, 3);
completeMultipartUpload(authInfo, completeMultipartUpload(authInfo,
completeRequest, log, err => { completeRequest, log, err => {
assert.deepStrictEqual(err, assert.strictEqual(err.is.EntityTooSmall, true);
errors.EntityTooSmall);
done(); done();
}); });
}); });
@ -1716,7 +1713,7 @@ describe('Multipart Upload API', () => {
bucketPut(authInfo, bucketPutRequest, log, () => bucketPut(authInfo, bucketPutRequest, log, () =>
objectPutPart(authInfo, partRequest, undefined, log, err => { objectPutPart(authInfo, partRequest, undefined, log, err => {
assert.strictEqual(err, errors.NoSuchUpload); assert.strictEqual(err.is.NoSuchUpload, true);
done(); done();
}) })
); );
@ -1831,7 +1828,7 @@ describe('Multipart Upload API', () => {
completeMultipartUpload(authInfo, completeRequest, log, err => { completeMultipartUpload(authInfo, completeRequest, log, err => {
// expect a failure here because we could not // expect a failure here because we could not
// remove the overview key // remove the overview key
assert.strictEqual(err, errors.InternalError); assert.strictEqual(err.is.InternalError, true);
next(null, eTag, testUploadId); next(null, eTag, testUploadId);
}); });
}, },
@ -2054,7 +2051,7 @@ describe('complete mpu with versioning', () => {
completeMultipartUpload(authInfo, completeRequest, log, err => { completeMultipartUpload(authInfo, completeRequest, log, err => {
// expect a failure here because we could not // expect a failure here because we could not
// remove the overview key // remove the overview key
assert.strictEqual(err, errors.InternalError); assert.strictEqual(err.is.InternalError, true);
next(null, eTag, testUploadId); next(null, eTag, testUploadId);
}); });
}, },

View File

@ -109,7 +109,7 @@ describe('objectCopyPart', () => {
_createObjectCopyPartRequest(destBucketName, uploadId, headers); _createObjectCopyPartRequest(destBucketName, uploadId, headers);
objectPutCopyPart( objectPutCopyPart(
authInfo, req, sourceBucketName, objectKey, undefined, log, err => { authInfo, req, sourceBucketName, objectKey, undefined, log, err => {
assert(err.InvalidArgument); assert.strictEqual(err.is.InvalidArgument, true);
assert.strictEqual(err.description, assert.strictEqual(err.description,
'The x-amz-copy-source-range value must be of the form ' + 'The x-amz-copy-source-range value must be of the form ' +
'bytes=first-last where first and last are the ' + 'bytes=first-last where first and last are the ' +

View File

@ -1,7 +1,6 @@
const assert = require('assert'); const assert = require('assert');
const async = require('async'); const async = require('async');
const crypto = require('crypto'); const crypto = require('crypto');
const { errors } = require('arsenal');
const xml2js = require('xml2js'); const xml2js = require('xml2js');
const { bucketPut } = require('../../../lib/api/bucketPut'); const { bucketPut } = require('../../../lib/api/bucketPut');
@ -93,8 +92,7 @@ describe('objectDelete API', () => {
assert.strictEqual(err, null); assert.strictEqual(err, null);
objectGet(authInfo, testGetObjectRequest, false, objectGet(authInfo, testGetObjectRequest, false,
log, err => { log, err => {
assert.deepStrictEqual(err, assert.strictEqual(err.is.NoSuchKey, true);
errors.NoSuchKey);
done(); done();
}); });
}); });
@ -117,10 +115,7 @@ describe('objectDelete API', () => {
assert.strictEqual(err, null); assert.strictEqual(err, null);
objectGet(authInfo, testGetObjectRequest, false, objectGet(authInfo, testGetObjectRequest, false,
log, err => { log, err => {
const expected = assert.strictEqual(err.is.NoSuchKey, true);
Object.assign({}, errors.NoSuchKey);
const received = Object.assign({}, err);
assert.deepStrictEqual(received, expected);
done(); done();
}); });
}); });
@ -183,7 +178,7 @@ describe('objectDelete API', () => {
const publicAuthInfo = makeAuthInfo(constants.publicId); const publicAuthInfo = makeAuthInfo(constants.publicId);
bucketPut(authInfo, testBucketPutRequest, log, () => { bucketPut(authInfo, testBucketPutRequest, log, () => {
objectDelete(publicAuthInfo, testDeleteRequest, log, err => { objectDelete(publicAuthInfo, testDeleteRequest, log, err => {
assert.deepStrictEqual(err, errors.AccessDenied); assert.strictEqual(err.is.AccessDenied, true);
done(); done();
}); });
}); });

View File

@ -1,7 +1,6 @@
const assert = require('assert'); const assert = require('assert');
const async = require('async'); const async = require('async');
const { parseString } = require('xml2js'); const { parseString } = require('xml2js');
const { errors } = require('arsenal');
const { bucketPut } = require('../../../lib/api/bucketPut'); const { bucketPut } = require('../../../lib/api/bucketPut');
const constants = require('../../../constants'); const constants = require('../../../constants');
@ -79,7 +78,7 @@ describe('objectGetACL API', () => {
'for a nonexistent object', done => { 'for a nonexistent object', done => {
bucketPut(authInfo, testBucketPutRequest, log, () => { bucketPut(authInfo, testBucketPutRequest, log, () => {
objectGetACL(authInfo, testGetACLRequest, log, err => { objectGetACL(authInfo, testGetACLRequest, log, err => {
assert.deepStrictEqual(err, errors.NoSuchKey); assert.strictEqual(err.is.NoSuchKey, true);
done(); done();
}); });
}); });

View File

@ -61,7 +61,7 @@ describe('getObjectLegalHold API', () => {
it('should return InvalidRequest error', done => { it('should return InvalidRequest error', done => {
objectGetLegalHold(authInfo, getObjectLegalHoldRequest, log, objectGetLegalHold(authInfo, getObjectLegalHoldRequest, log,
err => { err => {
assert.strictEqual(err.InvalidRequest, true); assert.strictEqual(err.is.InvalidRequest, true);
done(); done();
}); });
}); });
@ -84,8 +84,7 @@ describe('getObjectLegalHold API', () => {
done => { done => {
objectGetLegalHold(authInfo, getObjectLegalHoldRequest, log, objectGetLegalHold(authInfo, getObjectLegalHoldRequest, log,
err => { err => {
const error = err.NoSuchObjectLockConfiguration; assert.strictEqual(err.is.NoSuchObjectLockConfiguration, true);
assert.strictEqual(error, true);
done(); done();
}); });
}); });

View File

@ -64,7 +64,7 @@ describe('getObjectRetention API', () => {
it('should return InvalidRequest error', done => { it('should return InvalidRequest error', done => {
objectGetRetention(authInfo, getObjRetRequest, log, err => { objectGetRetention(authInfo, getObjRetRequest, log, err => {
assert.strictEqual(err.InvalidRequest, true); assert.strictEqual(err.is.InvalidRequest, true);
done(); done();
}); });
}); });
@ -85,7 +85,7 @@ describe('getObjectRetention API', () => {
it('should return NoSuchObjectLockConfiguration if no retention set', it('should return NoSuchObjectLockConfiguration if no retention set',
done => { done => {
objectGetRetention(authInfo, getObjRetRequest, log, err => { objectGetRetention(authInfo, getObjRetRequest, log, err => {
assert.strictEqual(err.NoSuchObjectLockConfiguration, true); assert.strictEqual(err.is.NoSuchObjectLockConfiguration, true);
done(); done();
}); });
}); });

View File

@ -1,5 +1,4 @@
const assert = require('assert'); const assert = require('assert');
const { errors } = require('arsenal');
const { bucketPut } = require('../../../lib/api/bucketPut'); const { bucketPut } = require('../../../lib/api/bucketPut');
const { cleanup, DummyRequestLogger, makeAuthInfo } = require('../helpers'); const { cleanup, DummyRequestLogger, makeAuthInfo } = require('../helpers');
@ -17,9 +16,9 @@ const postBody = Buffer.from('I am a body', 'utf8');
const correctMD5 = 'be747eb4b75517bf6b3cf7c5fbb62f3a'; const correctMD5 = 'be747eb4b75517bf6b3cf7c5fbb62f3a';
const incorrectMD5 = 'fkjwelfjlslfksdfsdfsdfsdfsdfsdj'; const incorrectMD5 = 'fkjwelfjlslfksdfsdfsdfsdfsdfsdj';
const objectName = 'objectName'; const objectName = 'objectName';
const date = new Date(); const masterDate = new Date();
const laterDate = date.setMinutes(date.getMinutes() + 30); const laterDate = new Date().setMinutes(masterDate.getMinutes() + 30);
const earlierDate = date.setMinutes(date.getMinutes() - 30); const earlierDate = new Date().setMinutes(masterDate.getMinutes() - 30);
const testPutBucketRequest = { const testPutBucketRequest = {
bucketName, bucketName,
namespace, namespace,
@ -60,7 +59,7 @@ describe('objectHead API', () => {
(err, resHeaders) => { (err, resHeaders) => {
assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`); assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`);
objectHead(authInfo, testGetRequest, log, err => { objectHead(authInfo, testGetRequest, log, err => {
assert.deepStrictEqual(err, errors.NotModified); assert.strictEqual(err.is.NotModified, true);
done(); done();
}); });
}); });
@ -83,8 +82,7 @@ describe('objectHead API', () => {
(err, resHeaders) => { (err, resHeaders) => {
assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`); assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`);
objectHead(authInfo, testGetRequest, log, err => { objectHead(authInfo, testGetRequest, log, err => {
assert.deepStrictEqual(err, assert.strictEqual(err.is.PreconditionFailed, true);
errors.PreconditionFailed);
done(); done();
}); });
}); });
@ -107,8 +105,7 @@ describe('objectHead API', () => {
(err, resHeaders) => { (err, resHeaders) => {
assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`); assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`);
objectHead(authInfo, testGetRequest, log, err => { objectHead(authInfo, testGetRequest, log, err => {
assert.deepStrictEqual(err, assert.strictEqual(err.is.PreconditionFailed, true);
errors.PreconditionFailed);
done(); done();
}); });
}); });
@ -131,7 +128,7 @@ describe('objectHead API', () => {
(err, resHeaders) => { (err, resHeaders) => {
assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`); assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`);
objectHead(authInfo, testGetRequest, log, err => { objectHead(authInfo, testGetRequest, log, err => {
assert.deepStrictEqual(err, errors.NotModified); assert.strictEqual(err.is.NotModified, true);
done(); done();
}); });
}); });
@ -171,16 +168,15 @@ describe('objectHead API', () => {
partNumber: '1', partNumber: '1',
}, },
}; };
const customizedInvalidRequestError = errors.InvalidRequest
.customizeDescription('Cannot specify both Range header and ' +
'partNumber query parameter.');
bucketPut(authInfo, testPutBucketRequest, log, () => { bucketPut(authInfo, testPutBucketRequest, log, () => {
objectPut(authInfo, testPutObjectRequest, undefined, log, err => { objectPut(authInfo, testPutObjectRequest, undefined, log, err => {
assert.strictEqual(err, null, `Error objectPut: ${err}`); assert.strictEqual(err, null, `Error objectPut: ${err}`);
objectHead(authInfo, testGetRequest, log, err => { objectHead(authInfo, testGetRequest, log, err => {
assert.deepStrictEqual(err, customizedInvalidRequestError); assert.strictEqual(err.is.InvalidRequest, true);
assert.deepStrictEqual(err.InvalidRequest, true); assert.strictEqual(err.description,
'Cannot specify both Range header and ' +
'partNumber query parameter.');
done(); done();
}); });
}); });
@ -198,15 +194,13 @@ describe('objectHead API', () => {
partNumber: 'nan', partNumber: 'nan',
}, },
}; };
const customizedInvalidArgumentError = errors.InvalidArgument
.customizeDescription('Part number must be a number.');
bucketPut(authInfo, testPutBucketRequest, log, () => { bucketPut(authInfo, testPutBucketRequest, log, () => {
objectPut(authInfo, testPutObjectRequest, undefined, log, err => { objectPut(authInfo, testPutObjectRequest, undefined, log, err => {
assert.strictEqual(err, null, `Error objectPut: ${err}`); assert.strictEqual(err, null, `Error objectPut: ${err}`);
objectHead(authInfo, testGetRequest, log, err => { objectHead(authInfo, testGetRequest, log, err => {
assert.deepStrictEqual(err, customizedInvalidArgumentError); assert.strictEqual(err.is.InvalidArgument, true);
assert.deepStrictEqual(err.InvalidArgument, true); assert.strictEqual(err.description, 'Part number must be a number.');
done(); done();
}); });
}); });

View File

@ -1,7 +1,7 @@
const assert = require('assert'); const assert = require('assert');
const async = require('async'); const async = require('async');
const moment = require('moment'); const moment = require('moment');
const { errors, s3middleware } = require('arsenal'); const { s3middleware } = require('arsenal');
const { bucketPut } = require('../../../lib/api/bucketPut'); const { bucketPut } = require('../../../lib/api/bucketPut');
const bucketPutObjectLock = require('../../../lib/api/bucketPutObjectLock'); const bucketPutObjectLock = require('../../../lib/api/bucketPutObjectLock');
@ -84,7 +84,7 @@ describe('parseTagFromQuery', () => {
it(`should ${behavior} if tag set: "${test.tagging}"`, done => { it(`should ${behavior} if tag set: "${test.tagging}"`, done => {
const result = parseTagFromQuery(test.tagging); const result = parseTagFromQuery(test.tagging);
if (test.error) { if (test.error) {
assert(result[test.error.status]); assert.strictEqual(result.is[test.error.status], true);
assert.strictEqual(result.code, test.error.statusCode); assert.strictEqual(result.code, test.error.statusCode);
} else { } else {
assert.deepStrictEqual(result, test.result); assert.deepStrictEqual(result, test.result);
@ -112,7 +112,7 @@ describe('objectPut API', () => {
it('should return an error if the bucket does not exist', done => { it('should return an error if the bucket does not exist', done => {
objectPut(authInfo, testPutObjectRequest, undefined, log, err => { objectPut(authInfo, testPutObjectRequest, undefined, log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -123,7 +123,7 @@ describe('objectPut API', () => {
log, () => { log, () => {
objectPut(authInfo, testPutObjectRequest, objectPut(authInfo, testPutObjectRequest,
undefined, log, err => { undefined, log, err => {
assert.deepStrictEqual(err, errors.AccessDenied); assert.strictEqual(err.is.AccessDenied, true);
done(); done();
}); });
}); });
@ -451,9 +451,8 @@ describe('objectPut API', () => {
bucketPut(authInfo, testPutBucketRequest, log, () => { bucketPut(authInfo, testPutBucketRequest, log, () => {
objectPut(authInfo, testPutObjectRequest, undefined, log, err => { objectPut(authInfo, testPutObjectRequest, undefined, log, err => {
assert.deepStrictEqual(err, errors.InvalidRequest assert.strictEqual(err.is.InvalidRequest, true);
.customizeDescription( assert.strictEqual(err.description, 'Bucket is missing ObjectLockConfiguration');
'Bucket is missing ObjectLockConfiguration'));
done(); done();
}); });
}); });
@ -592,7 +591,7 @@ describe('objectPut API with versioning', () => {
bucketPut(authInfo, testPutBucketRequest, log, () => { bucketPut(authInfo, testPutBucketRequest, log, () => {
objectPut(authInfo, testPutObjectRequest, undefined, log, objectPut(authInfo, testPutObjectRequest, undefined, log,
err => { err => {
assert.deepStrictEqual(err, errors.BadDigest); assert.strictEqual(err.is.BadDigest, true);
// orphan objects don't get deleted // orphan objects don't get deleted
// until the next tick // until the next tick
// in memory // in memory

View File

@ -1,5 +1,4 @@
const assert = require('assert'); const assert = require('assert');
const { errors } = require('arsenal');
const { bucketPut } = require('../../../lib/api/bucketPut'); const { bucketPut } = require('../../../lib/api/bucketPut');
const constants = require('../../../constants'); const constants = require('../../../constants');
@ -63,8 +62,7 @@ describe('putObjectACL API', () => {
(err, resHeaders) => { (err, resHeaders) => {
assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`); assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`);
objectPutACL(authInfo, testObjACLRequest, log, err => { objectPutACL(authInfo, testObjACLRequest, log, err => {
assert assert.strictEqual(err.is.InvalidArgument, true);
.deepStrictEqual(err, errors.InvalidArgument);
done(); done();
}); });
}); });
@ -208,8 +206,8 @@ describe('putObjectACL API', () => {
(err, resHeaders) => { (err, resHeaders) => {
assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`); assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`);
objectPutACL(authInfo, testObjACLRequest, log, err => { objectPutACL(authInfo, testObjACLRequest, log, err => {
assert.strictEqual(err, assert.strictEqual(
errors.UnresolvableGrantByEmailAddress); err.is.UnresolvableGrantByEmailAddress, true);
done(); done();
}); });
}); });
@ -274,8 +272,7 @@ describe('putObjectACL API', () => {
objectPut(authInfo, testPutObjectRequest, undefined, log, objectPut(authInfo, testPutObjectRequest, undefined, log,
() => { () => {
objectPutACL(authInfo, testObjACLRequest, log, err => { objectPutACL(authInfo, testObjACLRequest, log, err => {
assert.deepStrictEqual(err, assert.strictEqual(err.is.AccessDenied, true);
errors.AccessDenied);
done(); done();
}); });
}); });
@ -342,8 +339,8 @@ describe('putObjectACL API', () => {
(err, resHeaders) => { (err, resHeaders) => {
assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`); assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`);
objectPutACL(authInfo, testObjACLRequest, log, err => { objectPutACL(authInfo, testObjACLRequest, log, err => {
assert.strictEqual(err, assert.strictEqual(
errors.UnresolvableGrantByEmailAddress); err.is.UnresolvableGrantByEmailAddress, true);
done(); done();
}); });
}); });
@ -371,8 +368,7 @@ describe('putObjectACL API', () => {
(err, resHeaders) => { (err, resHeaders) => {
assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`); assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`);
objectPutACL(authInfo, testObjACLRequest, log, err => { objectPutACL(authInfo, testObjACLRequest, log, err => {
assert.deepStrictEqual(err, assert.strictEqual(err.is.MalformedACLError, true);
errors.MalformedACLError);
done(); done();
}); });
}); });
@ -400,7 +396,7 @@ describe('putObjectACL API', () => {
(err, resHeaders) => { (err, resHeaders) => {
assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`); assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`);
objectPutACL(authInfo, testObjACLRequest, log, err => { objectPutACL(authInfo, testObjACLRequest, log, err => {
assert.deepStrictEqual(err, errors.MalformedXML); assert.strictEqual(err.is.MalformedXML, true);
done(); done();
}); });
}); });
@ -427,7 +423,7 @@ describe('putObjectACL API', () => {
(err, resHeaders) => { (err, resHeaders) => {
assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`); assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`);
objectPutACL(authInfo, testObjACLRequest, log, err => { objectPutACL(authInfo, testObjACLRequest, log, err => {
assert.deepStrictEqual(err, errors.InvalidArgument); assert.strictEqual(err.is.InvalidArgument, true);
done(); done();
}); });
}); });
@ -455,7 +451,7 @@ describe('putObjectACL API', () => {
(err, resHeaders) => { (err, resHeaders) => {
assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`); assert.strictEqual(resHeaders.ETag, `"${correctMD5}"`);
objectPutACL(authInfo, testObjACLRequest, log, err => { objectPutACL(authInfo, testObjACLRequest, log, err => {
assert.deepStrictEqual(err, errors.InvalidArgument); assert.strictEqual(err.is.InvalidArgument, true);
done(); done();
}); });
}); });

View File

@ -55,7 +55,7 @@ describe('putObjectLegalHold API', () => {
it('should return InvalidRequest error', done => { it('should return InvalidRequest error', done => {
objectPutLegalHold(authInfo, putLegalHoldReq('ON'), log, err => { objectPutLegalHold(authInfo, putLegalHoldReq('ON'), log, err => {
assert.strictEqual(err.InvalidRequest, true); assert.strictEqual(err.is.InvalidRequest, true);
done(); done();
}); });
}); });

View File

@ -1,7 +1,6 @@
const assert = require('assert'); const assert = require('assert');
const moment = require('moment'); const moment = require('moment');
const { errors } = require('arsenal');
const { bucketPut } = require('../../../lib/api/bucketPut'); const { bucketPut } = require('../../../lib/api/bucketPut');
const objectPut = require('../../../lib/api/objectPut'); const objectPut = require('../../../lib/api/objectPut');
const objectPutRetention = require('../../../lib/api/objectPutRetention'); const objectPutRetention = require('../../../lib/api/objectPutRetention');
@ -99,7 +98,7 @@ describe('putObjectRetention API', () => {
it('should return InvalidRequest error', done => { it('should return InvalidRequest error', done => {
objectPutRetention(authInfo, putObjRetRequestGovernance, log, err => { objectPutRetention(authInfo, putObjRetRequestGovernance, log, err => {
assert.strictEqual(err.InvalidRequest, true); assert.strictEqual(err.is.InvalidRequest, true);
done(); done();
}); });
}); });
@ -134,7 +133,7 @@ describe('putObjectRetention API', () => {
objectPutRetention(authInfo, putObjRetRequestCompliance, log, err => { objectPutRetention(authInfo, putObjRetRequestCompliance, log, err => {
assert.ifError(err); assert.ifError(err);
return objectPutRetention(authInfo, putObjRetRequestGovernance, log, err => { return objectPutRetention(authInfo, putObjRetRequestGovernance, log, err => {
assert.deepStrictEqual(err, errors.AccessDenied); assert.strictEqual(err.is.AccessDenied, true);
done(); done();
}); });
}); });
@ -144,7 +143,7 @@ describe('putObjectRetention API', () => {
objectPutRetention(authInfo, putObjRetRequestCompliance, log, err => { objectPutRetention(authInfo, putObjRetRequestCompliance, log, err => {
assert.ifError(err); assert.ifError(err);
return objectPutRetention(authInfo, putObjRetRequestComplianceShorter, log, err => { return objectPutRetention(authInfo, putObjRetRequestComplianceShorter, log, err => {
assert.deepStrictEqual(err, errors.AccessDenied); assert.strictEqual(err.is.AccessDenied, true);
done(); done();
}); });
}); });
@ -155,7 +154,7 @@ describe('putObjectRetention API', () => {
objectPutRetention(authInfo, putObjRetRequestGovernance, log, err => { objectPutRetention(authInfo, putObjRetRequestGovernance, log, err => {
assert.ifError(err); assert.ifError(err);
return objectPutRetention(authInfo, putObjRetRequestGovernance, log, err => { return objectPutRetention(authInfo, putObjRetRequestGovernance, log, err => {
assert.deepStrictEqual(err, errors.AccessDenied); assert.strictEqual(err.is.AccessDenied, true);
done(); done();
}); });
}); });

View File

@ -37,8 +37,8 @@ const testPutObjectRequest = new DummyRequest({
function _checkError(err, code, errorName) { function _checkError(err, code, errorName) {
assert(err, 'Expected error but found none'); assert(err, 'Expected error but found none');
assert.strictEqual(err.is[errorName], true);
assert.strictEqual(err.code, code); assert.strictEqual(err.code, code);
assert(err[errorName]);
} }
function _generateSampleXml(key, value) { function _generateSampleXml(key, value) {

View File

@ -1,7 +1,6 @@
const assert = require('assert'); const assert = require('assert');
const async = require('async'); const async = require('async');
const { parseString } = require('xml2js'); const { parseString } = require('xml2js');
const { errors } = require('arsenal');
const { bucketPut } = require('../../../lib/api/bucketPut'); const { bucketPut } = require('../../../lib/api/bucketPut');
const constants = require('../../../constants'); const constants = require('../../../constants');
@ -79,7 +78,7 @@ describe('serviceGet API', () => {
it('should prevent anonymous user from accessing getService API', done => { it('should prevent anonymous user from accessing getService API', done => {
const publicAuthInfo = makeAuthInfo(constants.publicId); const publicAuthInfo = makeAuthInfo(constants.publicId);
serviceGet(publicAuthInfo, serviceGetRequest, log, err => { serviceGet(publicAuthInfo, serviceGetRequest, log, err => {
assert.deepStrictEqual(err, errors.AccessDenied); assert.strictEqual(err.is.AccessDenied, true);
done(); done();
}); });
}); });

View File

@ -1,6 +1,5 @@
const assert = require('assert'); const assert = require('assert');
const crypto = require('crypto'); const crypto = require('crypto');
const { errors } = require('arsenal');
const BucketInfo = require('arsenal').models.BucketInfo; const BucketInfo = require('arsenal').models.BucketInfo;
const bucketGet = require('../../../lib/api/bucketGet'); const bucketGet = require('../../../lib/api/bucketGet');
@ -101,7 +100,7 @@ describe('transient bucket handling', () => {
it('putBucket request should return error if ' + it('putBucket request should return error if ' +
'transient bucket created by different account', done => { 'transient bucket created by different account', done => {
bucketPut(otherAccountAuthInfo, baseTestRequest, log, err => { bucketPut(otherAccountAuthInfo, baseTestRequest, log, err => {
assert.deepStrictEqual(err, errors.BucketAlreadyExists); assert.strictEqual(err.is.BucketAlreadyExists, true);
serviceGet(otherAccountAuthInfo, serviceGetRequest, serviceGet(otherAccountAuthInfo, serviceGetRequest,
log, (err, data) => { log, (err, data) => {
parseString(data, (err, result) => { parseString(data, (err, result) => {
@ -237,7 +236,7 @@ describe('transient bucket handling', () => {
bucketDelete(authInfo, baseTestRequest, log, err => { bucketDelete(authInfo, baseTestRequest, log, err => {
assert.ifError(err); assert.ifError(err);
metadata.getBucket(bucketName, log, err => { metadata.getBucket(bucketName, log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -247,7 +246,7 @@ describe('transient bucket handling', () => {
'request is not from owner', done => { 'request is not from owner', done => {
bucketDelete(otherAccountAuthInfo, baseTestRequest, bucketDelete(otherAccountAuthInfo, baseTestRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.AccessDenied); assert.strictEqual(err.is.AccessDenied, true);
done(); done();
}); });
}); });
@ -260,7 +259,7 @@ describe('transient bucket handling', () => {
bucketGetRequest.query = {}; bucketGetRequest.query = {};
bucketGet(authInfo, bucketGetRequest, bucketGet(authInfo, bucketGetRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -273,7 +272,7 @@ describe('transient bucket handling', () => {
bucketGetACLRequest.query = { acl: '' }; bucketGetACLRequest.query = { acl: '' };
bucketGetACL(authInfo, bucketGetACLRequest, bucketGetACL(authInfo, bucketGetACLRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -281,7 +280,7 @@ describe('transient bucket handling', () => {
it('bucketGetCors request on transient bucket should return ' + it('bucketGetCors request on transient bucket should return ' +
'NoSuchBucket error', done => { 'NoSuchBucket error', done => {
bucketGetCors(authInfo, baseTestRequest, log, err => { bucketGetCors(authInfo, baseTestRequest, log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -297,7 +296,7 @@ describe('transient bucket handling', () => {
bucketPutCorsRequest.headers['content-md5'] = crypto.createHash('md5') bucketPutCorsRequest.headers['content-md5'] = crypto.createHash('md5')
.update(bucketPutCorsRequest.post, 'utf8').digest('base64'); .update(bucketPutCorsRequest.post, 'utf8').digest('base64');
bucketPutCors(authInfo, bucketPutCorsRequest, log, err => { bucketPutCors(authInfo, bucketPutCorsRequest, log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -305,7 +304,7 @@ describe('transient bucket handling', () => {
it('bucketDeleteCors request on transient bucket should return ' + it('bucketDeleteCors request on transient bucket should return ' +
'NoSuchBucket error', done => { 'NoSuchBucket error', done => {
bucketDeleteCors(authInfo, baseTestRequest, log, err => { bucketDeleteCors(authInfo, baseTestRequest, log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -313,7 +312,7 @@ describe('transient bucket handling', () => {
it('bucketGetWebsite request on transient bucket should return ' + it('bucketGetWebsite request on transient bucket should return ' +
'NoSuchBucket error', done => { 'NoSuchBucket error', done => {
bucketGetWebsite(authInfo, baseTestRequest, log, err => { bucketGetWebsite(authInfo, baseTestRequest, log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -326,7 +325,7 @@ describe('transient bucket handling', () => {
'<IndexDocument><Suffix>index.html</Suffix></IndexDocument>' + '<IndexDocument><Suffix>index.html</Suffix></IndexDocument>' +
'</WebsiteConfiguration>'; '</WebsiteConfiguration>';
bucketPutWebsite(authInfo, bucketPutWebsiteRequest, log, err => { bucketPutWebsite(authInfo, bucketPutWebsiteRequest, log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -334,7 +333,7 @@ describe('transient bucket handling', () => {
it('bucketDeleteWebsite request on transient bucket should return ' + it('bucketDeleteWebsite request on transient bucket should return ' +
'NoSuchBucket error', done => { 'NoSuchBucket error', done => {
bucketDeleteWebsite(authInfo, baseTestRequest, log, err => { bucketDeleteWebsite(authInfo, baseTestRequest, log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -343,7 +342,7 @@ describe('transient bucket handling', () => {
'error', done => { 'error', done => {
bucketHead(authInfo, baseTestRequest, bucketHead(authInfo, baseTestRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -357,7 +356,7 @@ describe('transient bucket handling', () => {
completeMpuRequest.query = { uploadId }; completeMpuRequest.query = { uploadId };
completeMultipartUpload(authInfo, completeMpuRequest, completeMultipartUpload(authInfo, completeMpuRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchUpload); assert.strictEqual(err.is.NoSuchUpload, true);
done(); done();
}); });
}); });
@ -371,7 +370,7 @@ describe('transient bucket handling', () => {
listRequest.query = { uploadId }; listRequest.query = { uploadId };
listParts(authInfo, listRequest, listParts(authInfo, listRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchUpload); assert.strictEqual(err.is.NoSuchUpload, true);
done(); done();
}); });
}); });
@ -396,7 +395,7 @@ describe('transient bucket handling', () => {
config.locationConstraints[locationConstraint]. config.locationConstraints[locationConstraint].
legacyAwsBehavior = true; legacyAwsBehavior = true;
multipartDelete(authInfo, deleteRequest, log, err => { multipartDelete(authInfo, deleteRequest, log, err => {
assert.deepStrictEqual(err, errors.NoSuchUpload); assert.strictEqual(err.is.NoSuchUpload, true);
done(); done();
}); });
}); });
@ -423,7 +422,7 @@ describe('transient bucket handling', () => {
partNumber: '1' }; partNumber: '1' };
objectPutPart(authInfo, putPartRequest, undefined, objectPutPart(authInfo, putPartRequest, undefined,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchUpload); assert.strictEqual(err.is.NoSuchUpload, true);
done(); done();
}); });
}); });
@ -435,7 +434,7 @@ describe('transient bucket handling', () => {
listRequest.query = {}; listRequest.query = {};
listMultipartUploads(authInfo, listRequest, listMultipartUploads(authInfo, listRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -445,7 +444,7 @@ describe('transient bucket handling', () => {
done => { done => {
objectGet(authInfo, baseTestRequest, false, objectGet(authInfo, baseTestRequest, false,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -454,7 +453,7 @@ describe('transient bucket handling', () => {
'NoSuchBucket error', done => { 'NoSuchBucket error', done => {
objectGetACL(authInfo, baseTestRequest, objectGetACL(authInfo, baseTestRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -463,7 +462,7 @@ describe('transient bucket handling', () => {
'NoSuchBucket error', done => { 'NoSuchBucket error', done => {
objectHead(authInfo, baseTestRequest, objectHead(authInfo, baseTestRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -472,7 +471,7 @@ describe('transient bucket handling', () => {
'NoSuchBucket error', done => { 'NoSuchBucket error', done => {
objectPutACL(authInfo, baseTestRequest, objectPutACL(authInfo, baseTestRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });
@ -481,7 +480,7 @@ describe('transient bucket handling', () => {
'NoSuchBucket error', done => { 'NoSuchBucket error', done => {
objectDelete(authInfo, baseTestRequest, objectDelete(authInfo, baseTestRequest,
log, err => { log, err => {
assert.deepStrictEqual(err, errors.NoSuchBucket); assert.strictEqual(err.is.NoSuchBucket, true);
done(); done();
}); });
}); });

View File

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

View File

@ -1,8 +1,6 @@
const assert = require('assert'); const assert = require('assert');
const async = require('async'); const async = require('async');
const { errors } = require('arsenal');
const BucketInfo = require('arsenal').models.BucketInfo; const BucketInfo = require('arsenal').models.BucketInfo;
const { cleanup, DummyRequestLogger } = require('../helpers'); const { cleanup, DummyRequestLogger } = require('../helpers');
const { isKeyInContents } const { isKeyInContents }
@ -39,7 +37,7 @@ describe('bucket API for getting, putting and deleting ' +
it('should return an error in response ' + it('should return an error in response ' +
'to getObjectMD when no such key', done => { 'to getObjectMD when no such key', done => {
metadata.getObjectMD(bucketName, 'notThere', {}, log, (err, value) => { metadata.getObjectMD(bucketName, 'notThere', {}, log, (err, value) => {
assert.deepStrictEqual(err, errors.NoSuchKey); assert.strictEqual(err.is.NoSuchKey, true);
assert.strictEqual(value, undefined); assert.strictEqual(value, undefined);
done(); done();
}); });
@ -52,7 +50,7 @@ describe('bucket API for getting, putting and deleting ' +
() => { () => {
metadata.getObjectMD(bucketName, 'objectToDelete', {}, log, metadata.getObjectMD(bucketName, 'objectToDelete', {}, log,
(err, value) => { (err, value) => {
assert.deepStrictEqual(err, errors.NoSuchKey); assert.strictEqual(err.is.NoSuchKey, true);
assert.strictEqual(value, undefined); assert.strictEqual(value, undefined);
done(); done();
}); });

View File

@ -40,7 +40,7 @@ describe('Location Constraint Check', () => {
createTestRequest('fail-region'), null, testBucket, log); createTestRequest('fail-region'), null, testBucket, log);
assert.strictEqual(backendInfoObj.err.code, 400, assert.strictEqual(backendInfoObj.err.code, 400,
'Expected "Invalid Argument" code error'); 'Expected "Invalid Argument" code error');
assert(backendInfoObj.err.InvalidArgument, 'Expected "Invalid ' + assert(backendInfoObj.err.is.InvalidArgument, 'Expected "Invalid ' +
'Argument" error'); 'Argument" error');
done(); done();
}); });

View File

@ -111,6 +111,23 @@
dependencies: dependencies:
dayjs "^1.10.5" 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": "@sinonjs/commons@^1.6.0", "@sinonjs/commons@^1.7.0", "@sinonjs/commons@^1.8.3":
version "1.8.3" version "1.8.3"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d" 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" resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==
"@types/async@^3.2.12":
version "3.2.12"
resolved "https://registry.yarnpkg.com/@types/async/-/async-3.2.12.tgz#0ebbfaf3f249ffa0fdc50179b07705f69c90d70c"
integrity sha512-4i4w4tfNDo73BOjk0qHcB2YJ8A2SjITCrU4BTsgdJFTsVr6atPDXa0T9r0QZTrX3axtWwkqpZqF4B3gR0TqBGw==
"@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: JSONStream@^1.0.0:
version "1.3.5" version "1.3.5"
resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" 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" resolved "https://registry.yarnpkg.com/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz#3bbc4275dd584cc1b10809b89d4e8b63a69e7675"
integrity sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog== integrity sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog==
"arsenal@git+https://github.com/scality/arsenal#7.10.15": "arsenal@git+https://github.com/scality/arsenal#ccbc1ed1":
version "7.10.15" version "7.10.19"
resolved "git+https://github.com/scality/arsenal#310834c237da624800ea6b4e291045808aa9bf80" resolved "git+https://github.com/scality/arsenal#ccbc1ed10c9115c31c08e9ba132887e449cb56d7"
dependencies: dependencies:
"@hapi/joi" "^15.1.0" "@types/async" "^3.2.12"
"@types/utf8" "^3.0.1"
JSONStream "^1.0.0" JSONStream "^1.0.0"
agentkeepalive "^4.1.3" agentkeepalive "^4.1.3"
ajv "6.12.2" ajv "6.12.2"
@ -412,6 +440,7 @@ arraybuffer.slice@~0.0.7:
hdclient scality/hdclient#1.1.0 hdclient scality/hdclient#1.1.0
ioredis "^4.28.5" ioredis "^4.28.5"
ipaddr.js "1.9.1" ipaddr.js "1.9.1"
joi "^17.6.0"
level "~5.0.1" level "~5.0.1"
level-sublevel "~6.6.5" level-sublevel "~6.6.5"
mongodb "^3.0.1" mongodb "^3.0.1"
@ -1304,7 +1333,7 @@ debug@2.6.9, debug@^2.1.1, debug@^2.2.0, debug@^2.6.8, debug@~2.6.9:
dependencies: dependencies:
ms "2.0.0" ms "2.0.0"
debug@4, debug@^4.3.3: debug@4:
version "4.3.4" version "4.3.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
@ -2037,7 +2066,7 @@ gar@^1.0.4:
resolved "https://registry.yarnpkg.com/gar/-/gar-1.0.4.tgz#f777bc7db425c0572fdeb52676172ca1ae9888b8" resolved "https://registry.yarnpkg.com/gar/-/gar-1.0.4.tgz#f777bc7db425c0572fdeb52676172ca1ae9888b8"
integrity sha512-w4n9cPWyP7aHxKxYHFQMegj7WIAsL/YX/C4Bs5Rr8s1H9M1rNtRWRsw+ovYMkXDQ5S4ZbYHsHAPmevPjPgw44w== integrity sha512-w4n9cPWyP7aHxKxYHFQMegj7WIAsL/YX/C4Bs5Rr8s1H9M1rNtRWRsw+ovYMkXDQ5S4ZbYHsHAPmevPjPgw44w==
gauge@^4.0.3: gauge@^4.0.0:
version "4.0.4" version "4.0.4"
resolved "https://registry.yarnpkg.com/gauge/-/gauge-4.0.4.tgz#52ff0652f2bbf607a989793d53b751bef2328dce" resolved "https://registry.yarnpkg.com/gauge/-/gauge-4.0.4.tgz#52ff0652f2bbf607a989793d53b751bef2328dce"
integrity sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg== integrity sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg==
@ -2891,6 +2920,17 @@ jmespath@0.16.0:
resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.16.0.tgz#b15b0a85dfd4d930d43e69ed605943c802785076" resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.16.0.tgz#b15b0a85dfd4d930d43e69ed605943c802785076"
integrity sha512-9FzQjJ7MATs1tSpnco1K6ayiYE3figslrXA72G2HQ/n76RzvYlofyi5QM+iX4YRs/pu3yzxlVQSST23+dMDknw== 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": "js-tokens@^3.0.0 || ^4.0.0":
version "4.0.0" version "4.0.0"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
@ -3881,13 +3921,13 @@ npm-run-all@~4.1.5:
string.prototype.padend "^3.0.0" string.prototype.padend "^3.0.0"
npmlog@^6.0.0: npmlog@^6.0.0:
version "6.0.2" version "6.0.1"
resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-6.0.2.tgz#c8166017a42f2dea92d6453168dd865186a70830" resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-6.0.1.tgz#06f1344a174c06e8de9c6c70834cfba2964bba17"
integrity sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg== integrity sha512-BTHDvY6nrRHuRfyjt1MAufLxYdVXZfd099H4+i1f0lPywNQyI4foeNXJRObB/uy+TYqUW0vAD9gbdSOXPst7Eg==
dependencies: dependencies:
are-we-there-yet "^3.0.0" are-we-there-yet "^3.0.0"
console-control-strings "^1.1.0" console-control-strings "^1.1.0"
gauge "^4.0.3" gauge "^4.0.0"
set-blocking "^2.0.0" set-blocking "^2.0.0"
number-is-nan@^1.0.0: number-is-nan@^1.0.0:
@ -4783,15 +4823,15 @@ socket.io@~2.3.0:
socket.io-parser "~3.4.0" socket.io-parser "~3.4.0"
socks-proxy-agent@^6.0.0: socks-proxy-agent@^6.0.0:
version "6.2.0" version "6.1.1"
resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-6.2.0.tgz#f6b5229cc0cbd6f2f202d9695f09d871e951c85e" resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-6.1.1.tgz#e664e8f1aaf4e1fb3df945f09e3d94f911137f87"
integrity sha512-wWqJhjb32Q6GsrUqzuFkukxb/zzide5quXYcMVpIjxalDBBYy2nqKCFQ/9+Ie4dvOYSQdOk3hUlZSdzZOd3zMQ== integrity sha512-t8J0kG3csjA4g6FTbsMOWws+7R7vuRC8aQ/wy3/1OWmsgwA68zs/+cExQ0koSitUDXqhufF/YJr9wtNMZHw5Ew==
dependencies: dependencies:
agent-base "^6.0.2" agent-base "^6.0.2"
debug "^4.3.3" debug "^4.3.1"
socks "^2.6.2" socks "^2.6.1"
socks@^2.6.2: socks@^2.6.1:
version "2.6.2" version "2.6.2"
resolved "https://registry.yarnpkg.com/socks/-/socks-2.6.2.tgz#ec042d7960073d40d94268ff3bb727dc685f111a" resolved "https://registry.yarnpkg.com/socks/-/socks-2.6.2.tgz#ec042d7960073d40d94268ff3bb727dc685f111a"
integrity sha512-zDZhHhZRY9PxRruRMR7kMhnf3I8hDs4S3f9RecfnGxvcBHQcKcIH/oUcEWffsfl1XxdYlA7nnlGbbTvPz9D8gA== integrity sha512-zDZhHhZRY9PxRruRMR7kMhnf3I8hDs4S3f9RecfnGxvcBHQcKcIH/oUcEWffsfl1XxdYlA7nnlGbbTvPz9D8gA==