Пример #1
0
        }, function (err) {
                if (err && verror.hasCauseWithName(err, jobDisabled)) {
                        self.log.info(err);
                        writeAuditRecord();
                        cb();
                        return;
                }
                if (err && (err.shouldNotFatal === undefined)) {
                        self.log.fatal(err, 'Error.');
                } else {
                        self.audit.cronFailed = 0;
                }

                self.recordJobs(opts, function (err2) {
                        if (err2 && err2.code !== 'ResourceNotFound' &&
                            err2.code !== 'DirectoryDoesNotExist') {
                                self.log.info(err2, 'Error saving audit.');
                        }

                        writeAuditRecord();

                        //Send back original error
                        cb(err);
                });
        });
Пример #2
0
 }, function (err) {
     if (err && VError.hasCauseWithName(err, 'EtagConflictError')) {
         callback(mod_err.createExistsErr('Rule', 'uuid'));
     } else {
         callback(err, new Rule({ value: raw }, app));
     }
 });
Пример #3
0
        mod_moray.putObj(app.moray, BUCKET, aggr, function (pErr) {
            if (pErr) {
                if (VError.hasCauseWithName(pErr, 'EtagConflictError')) {
                    callback(new errors.InvalidParamsError(
                        constants.msg.INVALID_PARAMS, [
                            errors.duplicateParam('name',
                            constants.msg.AGGR_NAME) ]));
                    return;
                }

                callback(pErr);
                return;
            }

            opts.app.publisher.publish({
                changeKind: {
                    resource: 'aggregation',
                    subResources: [ 'create' ]
                },
                changedResourceId: aggr.id,
                belongs_to_uuid: aggr.params.belongs_to_uuid,
                name: aggr.params.name,
                etag: aggr.etag
            }, function (cfErr) {
                if (cfErr) {
                    app.log.warn(cfErr,
                        'failed to publish changefeed entry ' +
                        'for aggr %s', aggr.id);
                }

                callback(null, aggr);
            });
        });
Пример #4
0
 backend.getObject(bucket, uuid, function (err, obj) {
     if (VError.hasCauseWithName(err, 'ObjectNotFoundError')) {
         backend.putObject(bucket, uuid, pkg, meta, cb);
     } else {
         cb(err || 'ObjectAlreadyExistsError');
     }
 });
Пример #5
0
 dom.on('error', function (err) {
     clearTimeout(timeout);
     t.ok(err);
     t.ok(err instanceof Error);
     t.ok(VError.hasCauseWithName(err, 'FastRequestError'));
     t.end();
 });
Пример #6
0
 self.commitUpload(bogus, [], function (err, upload) {
     t.ok(err);
     if (!err) {
         return (t.end());
     }
     t.ok(verror.hasCauseWithName(err, 'ResourceNotFoundError'));
     t.end();
 });
Пример #7
0
                    function onGetVolume(getVolumeErr) {
                        t.ok(verror.hasCauseWithName(getVolumeErr,
                            'VolumeNotFoundError'), 'expected ' +
                            'VolumeNotFoundError error, got: ' +
                            (getVolumeErr ? getVolumeErr.name :
                            JSON.stringify(getVolumeErr)));

                        t.end();
                });
Пример #8
0
 self.writeTestObject(bogus, pn, function (err, res) {
     t.ok(err);
     if (!err) {
         return (t.end());
     }
     t.ok(verror.hasCauseWithName(err, 'DirectoryDoesNotExistError'));
     t.checkResponse(res, 404);
     t.end();
 });
Пример #9
0
 self.userClient.get(self.redirectPath(pn), opts, function (err2) {
     t.ok(err2);
     if (!err2) {
         return (t.end());
     }
     t.ok(verror.hasCauseWithName(err2, 'AuthorizationFailedError'),
         err2);
     t.end();
 });
Пример #10
0
 self.writeTestObjectSubuser(self.uploadId, pn, function (err2, res) {
     t.ok(err2);
     if (!err2) {
         return (t.end());
     }
     t.ok(verror.hasCauseWithName(err2, 'NoMatchingRoleTagError'),
         err2);
     t.end();
 });
Пример #11
0
 self.getUploadSubuser(self.uploadId, function (err2, upload) {
     t.ok(err2);
     if (!err2) {
         return (t.end());
     }
     t.ok(verror.hasCauseWithName(err2, 'AuthorizationFailedError'),
         err2);
     t.end();
 });
Пример #12
0
            res.on('error', function (err) {
                if (VError.hasCauseWithName(err, errnom)) {
                    t.pass(msg);
                } else {
                    t.ifError(err, msg);
                }

                cb();
            });
Пример #13
0
 self.commitUpload(self.uploadId, undefined, function (err2) {
     t.ok(err2);
     if (!err2) {
         return (t.end());
     }
     t.ok(verror.hasCauseWithName(err2,
         'MultipartUploadInvalidArgumentError'));
     t.end();
 });
Пример #14
0
            res.on('error', function (err) {
                if (VError.hasCauseWithName(err, 'InvalidQueryError')) {
                    t.pass(msg);
                } else {
                    t.ifError(err, msg);
                }

                cb();
            });
Пример #15
0
 self.client.unlink(p, function (err2, res) {
     t.ok(err2);
     if (!err2) {
         return (t.end());
     }
     t.checkResponse(res, 405);
     t.ok(verror.hasCauseWithName(err2, 'MethodNotAllowedError'), err2);
     t.end();
 });
Пример #16
0
 self.createUploadSubuser(self.path, {}, function (err) {
     t.ok(err);
     if (!err) {
         return (t.end());
     }
     t.ok(verror.hasCauseWithName(err,
         'AuthorizationFailedError'), err);
     t.end();
 });
Пример #17
0
        self.client.jsonClient.post(options, {}, function (err2, _, res) {
            t.ok(err2);
            if (!err2) {
                return (t.end());
            }

            t.checkResponse(res, 404);
            t.ok(verror.hasCauseWithName(err2, 'ResourceNotFoundError'));
            t.end();
        });
Пример #18
0
 self.client.put(p, stream, opts, function (err, res) {
     t.ok(err);
     if (!err) {
         return (t.end());
     }
     t.checkResponse(res, 400);
     t.ok(verror.hasCauseWithName(err,
         'OperationNotAllowedOnRootDirectoryError'), err);
     t.end();
 });
Пример #19
0
 self.client.put(self.uploadPath(pn), s, opts, function (err2, res) {
     t.ok(err2);
     if (!err2) {
         return (t.end());
     }
     t.checkResponse(res, 409);
     t.ok(verror.hasCauseWithName(err2,
         'MultipartUploadInvalidArgumentError'));
     t.end();
 });
Пример #20
0
 self.writeTestObject(self.uploadId, pn, function (err2, res) {
     t.ok(err2);
     if (!err2) {
         return (t.end());
     }
     t.checkResponse(res, 409);
     t.ok(verror.hasCauseWithName(err2,
         'MultipartUploadInvalidArgumentError'));
     t.end();
 });
Пример #21
0
 self.commitUpload(self.uploadId, parts, function (err3) {
     if (!err3) {
         t.fail('commit specified > 10000 parts');
         t.end();
         return;
     }
     t.ok(verror.hasCauseWithName(err3,
         'MultipartUploadInvalidArgumentError'));
     t.end();
 });
Пример #22
0
        self.commitUpload(self.uploadId, [], function (err2) {
            if (!err2) {
                t.fail('invalid object path (parent is top-level directory)');
                t.end();
                return;
            }

            t.ok(verror.hasCauseWithName(err2, 'DirectoryDoesNotExistError'));
             t.end();
        });
Пример #23
0
 self.client.unlink(self.uploadPath(pn), function (err3, res) {
     t.ok(err3);
     if (!err3) {
         return (t.end());
     }
     t.checkResponse(res, 405);
     t.ok(verror.hasCauseWithName(err3, 'MethodNotAllowedError'),
         err3);
     t.end();
 });
Пример #24
0
 self.client.jsonClient.post(opts, {}, function (err4, _, res) {
     t.ok(err4);
     if (!err4) {
         return (t.end());
     }
     t.checkResponse(res, 405);
     t.ok(verror.hasCauseWithName(err4, 'MethodNotAllowedError'),
         err4);
     t.end();
 });
Пример #25
0
            self.commitUpload(self.uploadId, etags, function (err2) {
                if (!err2) {
                    t.fail('non-final part has less than minimum size');
                    t.end();
                    return;
                }

                t.ok(verror.hasCauseWithName(err2,
                    'MultipartUploadInvalidArgumentError'));
                t.end();
            });
Пример #26
0
            self.commitUpload(self.uploadId, ['foobar'], function (err3) {
                if (!err3) {
                    t.fail('commit part 0 has incorrect etag');
                    t.end();
                    return;
                }

                t.ok(verror.hasCauseWithName(err3,
                    'MultipartUploadInvalidArgumentError'));
                t.end();
            });
Пример #27
0
            self.commitUpload(self.uploadId, ['', etag, ''], function (err3) {
                if (!err3) {
                    t.fail('commit parts 0 and 2 have empty etags');
                    t.end();
                    return;
                }

                t.ok(verror.hasCauseWithName(err3,
                    'MultipartUploadInvalidArgumentError'));
                t.end();
            });
Пример #28
0
        self.commitUpload(self.uploadId, [], function (err2) {
            if (!err2) {
                t.fail('upload created under a different account');
                t.end();
                return;
            }

            t.ok(verror.hasCauseWithName(err2,
                'AccountDoesNotExistError'));
            t.end();
        });
Пример #29
0
        self.commitUpload(self.uploadId, [], function (err2) {
            if (!err2) {
                t.fail('invalid object path (top-level directory)');
                t.end();
                return;
            }

            t.ok(verror.hasCauseWithName(err2,
                'OperationNotAllowedOnDirectoryError'));
             t.end();
        });
Пример #30
0
 self.client.put(p, s, opts, function (err2, res) {
     t.ok(err2);
     if (!err2) {
         return (t.end());
     }
     // For PUTS, muskie interprets "commit" as the partNum
     t.checkResponse(res, 409);
     t.ok(verror.hasCauseWithName(err2,
         'MultipartUploadInvalidArgumentError'), err2);
     t.end();
 });