chore: update deps + fix linting + .npmrc
This commit is contained in:
parent
6d23c2edd1
commit
5ee731eafd
|
@ -600,11 +600,13 @@ module.exports = function(ACL) {
|
|||
break;
|
||||
case ACL.USER:
|
||||
this.userModel.findOne(
|
||||
{where: {or: [{username: id}, {email: id}, {id: id}]}}, cb);
|
||||
{where: {or: [{username: id}, {email: id}, {id: id}]}}, cb
|
||||
);
|
||||
break;
|
||||
case ACL.APP:
|
||||
this.applicationModel.findOne(
|
||||
{where: {or: [{name: id}, {email: id}, {id: id}]}}, cb);
|
||||
{where: {or: [{name: id}, {email: id}, {id: id}]}}, cb
|
||||
);
|
||||
break;
|
||||
default:
|
||||
// try resolving a user model with a name matching the principalType
|
||||
|
@ -612,7 +614,8 @@ module.exports = function(ACL) {
|
|||
if (userModel) {
|
||||
userModel.findOne(
|
||||
{where: {or: [{username: id}, {email: id}, {id: id}]}},
|
||||
cb);
|
||||
cb
|
||||
);
|
||||
} else {
|
||||
process.nextTick(function() {
|
||||
var err = new Error(g.f('Invalid principal type: %s', type));
|
||||
|
|
|
@ -502,7 +502,8 @@ module.exports = function(Change) {
|
|||
async.each(
|
||||
changes,
|
||||
function(c, next) { c.rectify(next); },
|
||||
cb);
|
||||
cb
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -691,8 +692,10 @@ module.exports = function(Change) {
|
|||
conflict.SourceModel.updateLastChange(
|
||||
conflict.modelId,
|
||||
{prev: targetChange.rev},
|
||||
cb);
|
||||
});
|
||||
cb
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -724,7 +727,8 @@ module.exports = function(Change) {
|
|||
}
|
||||
var inst = new conflict.SourceModel(
|
||||
target.toObject(),
|
||||
{persisted: true});
|
||||
{persisted: true}
|
||||
);
|
||||
inst.save(done);
|
||||
});
|
||||
|
||||
|
|
|
@ -226,7 +226,8 @@ function throwNotAttached(modelName, methodName) {
|
|||
'The %s method has not been setup. ' +
|
||||
'The {{KeyValueModel}} has not been correctly attached ' +
|
||||
'to a {{DataSource}}!',
|
||||
modelName, methodName, methodName));
|
||||
modelName, methodName, methodName
|
||||
));
|
||||
}
|
||||
|
||||
function convertNullToNotFoundError(ctx, cb) {
|
||||
|
|
|
@ -47,7 +47,8 @@ module.exports = function(Scope) {
|
|||
if (callback) callback(err);
|
||||
} else {
|
||||
aclModel.checkPermission(
|
||||
aclModel.SCOPE, scope.id, model, property, accessType, callback);
|
||||
aclModel.SCOPE, scope.id, model, property, accessType, callback
|
||||
);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -744,8 +744,9 @@ module.exports = function(User) {
|
|||
if (!confirmMethod) {
|
||||
throw new Error(
|
||||
'Cannot build user verification URL, ' +
|
||||
'the default confirm method is not public. ' +
|
||||
'Please provide the URL in verifyOptions.verifyHref.');
|
||||
'the default confirm method is not public. ' +
|
||||
'Please provide the URL in verifyOptions.verifyHref.'
|
||||
);
|
||||
}
|
||||
|
||||
const urlPath = joinUrlPath(
|
||||
|
@ -1315,7 +1316,8 @@ module.exports = function(User) {
|
|||
// This is a programmer's error, use the default status code 500
|
||||
return next(new Error(
|
||||
'Invalid use of "options.setPassword". Only "password" can be ' +
|
||||
'changed when using this option.'));
|
||||
'changed when using this option.'
|
||||
));
|
||||
}
|
||||
|
||||
return next();
|
||||
|
@ -1327,7 +1329,8 @@ module.exports = function(User) {
|
|||
|
||||
const err = new Error(
|
||||
'Changing user password via patch/replace API is not allowed. ' +
|
||||
'Use changePassword() or setPassword() instead.');
|
||||
'Use changePassword() or setPassword() instead.'
|
||||
);
|
||||
err.statusCode = 401;
|
||||
err.code = 'PASSWORD_CHANGE_NOT_ALLOWED';
|
||||
next(err);
|
||||
|
|
|
@ -357,7 +357,8 @@ app.enableAuth = function(options) {
|
|||
var Model = app.registry.findModel(m);
|
||||
if (!Model) {
|
||||
throw new Error(
|
||||
g.f('Authentication requires model %s to be defined.', m));
|
||||
g.f('Authentication requires model %s to be defined.', m)
|
||||
);
|
||||
}
|
||||
|
||||
if (Model.dataSource || Model.app) return;
|
||||
|
@ -483,7 +484,8 @@ app._verifyAuthModelRelations = function() {
|
|||
'custom User subclass, but does not fix AccessToken relations ' +
|
||||
'to use this new model.\n' +
|
||||
'Learn more at http://ibm.biz/setup-loopback-auth',
|
||||
Model.modelName, userName, userName);
|
||||
Model.modelName, userName, userName
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -491,7 +493,8 @@ app._verifyAuthModelRelations = function() {
|
|||
'The model %j does not have "belongsTo User-like model" relation ' +
|
||||
'configured.\n' +
|
||||
'Learn more at http://ibm.biz/setup-loopback-auth',
|
||||
Model.modelName);
|
||||
Model.modelName
|
||||
);
|
||||
}
|
||||
|
||||
function verifyUserRelations(Model) {
|
||||
|
@ -504,7 +507,8 @@ app._verifyAuthModelRelations = function() {
|
|||
'The app configuration follows the multiple user models setup ' +
|
||||
'as described in http://ibm.biz/setup-loopback-auth',
|
||||
'The built-in role resolver $owner is not currently compatible ' +
|
||||
'with this configuration and should not be used in production.');
|
||||
'with this configuration and should not be used in production.'
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -520,7 +524,8 @@ app._verifyAuthModelRelations = function() {
|
|||
'AccessToken subclass, but does not fix User relations to use this ' +
|
||||
'new model.\n' +
|
||||
'Learn more at http://ibm.biz/setup-loopback-auth',
|
||||
Model.modelName, accessTokenName, accessTokenName);
|
||||
Model.modelName, accessTokenName, accessTokenName
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -528,13 +533,15 @@ app._verifyAuthModelRelations = function() {
|
|||
'The model %j does not have "hasMany AccessToken-like models" relation ' +
|
||||
'configured.\n' +
|
||||
'Learn more at http://ibm.biz/setup-loopback-auth',
|
||||
Model.modelName);
|
||||
Model.modelName
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
app.boot = function(options) {
|
||||
throw new Error(
|
||||
g.f('{{`app.boot`}} was removed, use the new module {{loopback-boot}} instead'));
|
||||
g.f('{{`app.boot`}} was removed, use the new module {{loopback-boot}} instead')
|
||||
);
|
||||
};
|
||||
|
||||
function dataSourcesFromConfig(name, config, connectorRegistry, registry) {
|
||||
|
|
|
@ -12,47 +12,58 @@ module.exports = function(registry) {
|
|||
|
||||
registry.KeyValueModel = createModel(
|
||||
require('../common/models/key-value-model.json'),
|
||||
require('../common/models/key-value-model.js'));
|
||||
require('../common/models/key-value-model.js')
|
||||
);
|
||||
|
||||
registry.Email = createModel(
|
||||
require('../common/models/email.json'),
|
||||
require('../common/models/email.js'));
|
||||
require('../common/models/email.js')
|
||||
);
|
||||
|
||||
registry.Application = createModel(
|
||||
require('../common/models/application.json'),
|
||||
require('../common/models/application.js'));
|
||||
require('../common/models/application.js')
|
||||
);
|
||||
|
||||
registry.AccessToken = createModel(
|
||||
require('../common/models/access-token.json'),
|
||||
require('../common/models/access-token.js'));
|
||||
require('../common/models/access-token.js')
|
||||
);
|
||||
|
||||
registry.User = createModel(
|
||||
require('../common/models/user.json'),
|
||||
require('../common/models/user.js'));
|
||||
require('../common/models/user.js')
|
||||
);
|
||||
|
||||
registry.RoleMapping = createModel(
|
||||
require('../common/models/role-mapping.json'),
|
||||
require('../common/models/role-mapping.js'));
|
||||
require('../common/models/role-mapping.js')
|
||||
);
|
||||
|
||||
registry.Role = createModel(
|
||||
require('../common/models/role.json'),
|
||||
require('../common/models/role.js'));
|
||||
require('../common/models/role.js')
|
||||
);
|
||||
|
||||
registry.ACL = createModel(
|
||||
require('../common/models/acl.json'),
|
||||
require('../common/models/acl.js'));
|
||||
require('../common/models/acl.js')
|
||||
);
|
||||
|
||||
registry.Scope = createModel(
|
||||
require('../common/models/scope.json'),
|
||||
require('../common/models/scope.js'));
|
||||
require('../common/models/scope.js')
|
||||
);
|
||||
|
||||
registry.Change = createModel(
|
||||
require('../common/models/change.json'),
|
||||
require('../common/models/change.js'));
|
||||
require('../common/models/change.js')
|
||||
);
|
||||
|
||||
registry.Checkpoint = createModel(
|
||||
require('../common/models/checkpoint.json'),
|
||||
require('../common/models/checkpoint.js'));
|
||||
require('../common/models/checkpoint.js')
|
||||
);
|
||||
|
||||
function createModel(definitionJson, customizeFn) {
|
||||
// Clone the JSON definition to allow applications
|
||||
|
|
|
@ -15,20 +15,23 @@ module.exports = function(loopback) {
|
|||
throw new Error(g.f(
|
||||
'%s was removed in version 3.0. See %s for more details.',
|
||||
'loopback.getCurrentContext()',
|
||||
'http://loopback.io/doc/en/lb2/Using-current-context.html'));
|
||||
'http://loopback.io/doc/en/lb2/Using-current-context.html'
|
||||
));
|
||||
};
|
||||
|
||||
loopback.runInContext = function(fn) {
|
||||
throw new Error(g.f(
|
||||
'%s was removed in version 3.0. See %s for more details.',
|
||||
'loopback.runInContext()',
|
||||
'http://loopback.io/doc/en/lb2/Using-current-context.html'));
|
||||
'http://loopback.io/doc/en/lb2/Using-current-context.html'
|
||||
));
|
||||
};
|
||||
|
||||
loopback.createContext = function(scopeName) {
|
||||
throw new Error(g.f(
|
||||
'%s was removed in version 3.0. See %s for more details.',
|
||||
'loopback.createContext()',
|
||||
'http://loopback.io/doc/en/lb2/Using-current-context.html'));
|
||||
'http://loopback.io/doc/en/lb2/Using-current-context.html'
|
||||
));
|
||||
};
|
||||
};
|
||||
|
|
|
@ -251,11 +251,13 @@ module.exports = function(registry) {
|
|||
if ('injectOptionsFromRemoteContext' in options) {
|
||||
console.warn(g.f(
|
||||
'%s is using model setting %s which is no longer available.',
|
||||
typeName, 'injectOptionsFromRemoteContext'));
|
||||
typeName, 'injectOptionsFromRemoteContext'
|
||||
));
|
||||
console.warn(g.f(
|
||||
'Please rework your app to use the offical solution for injecting ' +
|
||||
'"options" argument from request context,\nsee %s',
|
||||
'http://loopback.io/doc/en/lb3/Using-current-context.html'));
|
||||
'http://loopback.io/doc/en/lb3/Using-current-context.html'
|
||||
));
|
||||
}
|
||||
|
||||
// resolve relation functions
|
||||
|
|
|
@ -1231,7 +1231,8 @@ module.exports = function(registry) {
|
|||
function(filter, pagingCallback) {
|
||||
sourceModel.changes(since.source, filter, pagingCallback);
|
||||
},
|
||||
debug.enabled ? log : cb);
|
||||
debug.enabled ? log : cb
|
||||
);
|
||||
|
||||
function log(err, result) {
|
||||
if (err) return cb(err);
|
||||
|
@ -1248,7 +1249,8 @@ module.exports = function(registry) {
|
|||
function(smallArray, chunkCallback) {
|
||||
return targetModel.diff(since.target, smallArray, chunkCallback);
|
||||
},
|
||||
debug.enabled ? log : cb);
|
||||
debug.enabled ? log : cb
|
||||
);
|
||||
|
||||
function log(err, result) {
|
||||
if (err) return cb(err);
|
||||
|
@ -1276,7 +1278,8 @@ module.exports = function(registry) {
|
|||
function(smallArray, chunkCallback) {
|
||||
return sourceModel.createUpdates(smallArray, chunkCallback);
|
||||
},
|
||||
cb);
|
||||
cb
|
||||
);
|
||||
} else {
|
||||
// nothing to replicate
|
||||
done();
|
||||
|
@ -1308,7 +1311,8 @@ module.exports = function(registry) {
|
|||
return cb();
|
||||
}
|
||||
cb(err);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function checkpoints() {
|
||||
|
@ -1526,14 +1530,16 @@ module.exports = function(registry) {
|
|||
return cb(new Error(
|
||||
g.f('Cannot apply bulk updates, ' +
|
||||
'the connector does not correctly report ' +
|
||||
'the number of updated records.')));
|
||||
'the number of updated records.')
|
||||
));
|
||||
|
||||
default:
|
||||
debug('%s.updateAll modified unexpected number of instances: %j',
|
||||
Model.modelName, count);
|
||||
return cb(new Error(
|
||||
g.f('Bulk update failed, the connector has modified unexpected ' +
|
||||
'number of records: %s', JSON.stringify(count))));
|
||||
'number of records: %s', JSON.stringify(count))
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1608,14 +1614,16 @@ module.exports = function(registry) {
|
|||
return cb(new Error(
|
||||
g.f('Cannot apply bulk updates, ' +
|
||||
'the connector does not correctly report ' +
|
||||
'the number of deleted records.')));
|
||||
'the number of deleted records.')
|
||||
));
|
||||
|
||||
default:
|
||||
debug('%s.deleteAll modified unexpected number of instances: %j',
|
||||
Model.modelName, count);
|
||||
return cb(new Error(
|
||||
g.f('Bulk update failed, the connector has deleted unexpected ' +
|
||||
'number of records: %s', JSON.stringify(count))));
|
||||
'number of records: %s', JSON.stringify(count))
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1770,7 +1778,8 @@ module.exports = function(registry) {
|
|||
const additionalChangeModelProperties =
|
||||
this.settings.additionalChangeModelProperties || {};
|
||||
|
||||
this.Change = BaseChangeModel.extend(this.modelName + '-change',
|
||||
this.Change = BaseChangeModel.extend(
|
||||
this.modelName + '-change',
|
||||
additionalChangeModelProperties,
|
||||
{trackModel: this}
|
||||
);
|
||||
|
|
|
@ -244,7 +244,8 @@ Registry.prototype.configureModel = function(ModelCtor, config) {
|
|||
g.warn(
|
||||
'The configuration of `%s` is missing {{`dataSource`}} property.\n' +
|
||||
'Use `null` or `false` to mark models not attached to any data source.',
|
||||
modelName);
|
||||
modelName
|
||||
);
|
||||
}
|
||||
|
||||
var newMethodNames = config.methods && Object.keys(config.methods);
|
||||
|
@ -253,7 +254,8 @@ Registry.prototype.configureModel = function(ModelCtor, config) {
|
|||
if (hasNewMethods && hasDescendants) {
|
||||
g.warn(
|
||||
'Child models of `%s` will not inherit newly defined remote methods %s.',
|
||||
modelName, newMethodNames);
|
||||
modelName, newMethodNames
|
||||
);
|
||||
}
|
||||
|
||||
// Remote methods
|
||||
|
|
|
@ -28,7 +28,8 @@ function createPromiseCallback() {
|
|||
function throwPromiseNotDefined() {
|
||||
throw new Error(
|
||||
'Your Node runtime does support ES6 Promises. ' +
|
||||
'Set "global.Promise" to your preferred implementation of promises.');
|
||||
'Set "global.Promise" to your preferred implementation of promises.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
22
package.json
22
package.json
|
@ -68,20 +68,20 @@
|
|||
"browserify": "^13.1.0",
|
||||
"chai": "^3.5.0",
|
||||
"cookie-parser": "^1.3.4",
|
||||
"coveralls": "^2.11.15",
|
||||
"coveralls": "^3.0.2",
|
||||
"dirty-chai": "^1.2.2",
|
||||
"eslint": "^4.18.2",
|
||||
"eslint-config-loopback": "^10.0.0",
|
||||
"eslint-plugin-mocha": "^4.11.0",
|
||||
"eslint": "^5.3.0",
|
||||
"eslint-config-loopback": "^11.0.0",
|
||||
"eslint-plugin-mocha": "^5.1.0",
|
||||
"express-session": "^1.14.0",
|
||||
"grunt": "^1.0.1",
|
||||
"grunt-browserify": "^5.0.0",
|
||||
"grunt-cli": "^1.2.0",
|
||||
"grunt-contrib-uglify": "^2.0.0",
|
||||
"grunt-contrib-uglify": "^3.4.0",
|
||||
"grunt-contrib-watch": "^1.0.0",
|
||||
"grunt-eslint": "^20.1.0",
|
||||
"grunt-eslint": "^21.0.0",
|
||||
"grunt-karma": "^2.0.0",
|
||||
"grunt-mocha-test": "^0.12.7",
|
||||
"grunt-mocha-test": "^0.13.3",
|
||||
"karma": "^1.1.2",
|
||||
"karma-browserify": "^5.1.1",
|
||||
"karma-chrome-launcher": "^1.0.1",
|
||||
|
@ -94,13 +94,13 @@
|
|||
"karma-script-launcher": "^1.0.0",
|
||||
"loopback-boot": "^2.7.0",
|
||||
"loopback-context": "^1.0.0",
|
||||
"mocha": "^3.0.0",
|
||||
"mocha": "^5.2.0",
|
||||
"nyc": "^10.1.2",
|
||||
"phantomjs-prebuilt": "^2.1.7",
|
||||
"sinon": "^1.13.0",
|
||||
"sinon-chai": "^2.8.0",
|
||||
"sinon": "^6.1.4",
|
||||
"sinon-chai": "^3.2.0",
|
||||
"strong-error-handler": "^3.0.0",
|
||||
"strong-task-emitter": "^0.0.6",
|
||||
"strong-task-emitter": "^0.0.8",
|
||||
"supertest": "^3.0.0"
|
||||
},
|
||||
"repository": {
|
||||
|
|
|
@ -10,5 +10,6 @@ module.exports = function() {
|
|||
throw new Error(g.f(
|
||||
'%s middleware was removed in version 3.0. See %s for more details.',
|
||||
'loopback#context',
|
||||
'http://loopback.io/doc/en/lb2/Using-current-context.html'));
|
||||
'http://loopback.io/doc/en/lb2/Using-current-context.html'
|
||||
));
|
||||
};
|
||||
|
|
|
@ -45,7 +45,8 @@ function rest() {
|
|||
throw new Error(g.f(
|
||||
'%s was removed in version 3.0. See %s for more details.',
|
||||
'remoting.context option',
|
||||
'http://loopback.io/doc/en/lb2/Using-current-context.html'));
|
||||
'http://loopback.io/doc/en/lb2/Using-current-context.html'
|
||||
));
|
||||
}
|
||||
|
||||
if (app.isAuthEnabled) {
|
||||
|
|
|
@ -40,7 +40,8 @@ function rewriteUserLiteral(req, currentUserLiteral, next) {
|
|||
debug(
|
||||
'URL %s matches current-user literal %s,' +
|
||||
' but no (valid) access token was provided.',
|
||||
req.url, currentUserLiteral);
|
||||
req.url, currentUserLiteral
|
||||
);
|
||||
|
||||
var e = new Error(g.f('Authorization Required'));
|
||||
e.status = e.statusCode = 401;
|
||||
|
|
|
@ -75,10 +75,12 @@ describe('access control - integration', function() {
|
|||
lt.it.shouldBeDeniedWhenCalledByUser(CURRENT_USER, 'GET', urlForUser);
|
||||
|
||||
lt.it.shouldBeAllowedWhenCalledAnonymously(
|
||||
'POST', '/api/users', newUserData());
|
||||
'POST', '/api/users', newUserData()
|
||||
);
|
||||
|
||||
lt.it.shouldBeAllowedWhenCalledByUser(
|
||||
CURRENT_USER, 'POST', '/api/users', newUserData());
|
||||
CURRENT_USER, 'POST', '/api/users', newUserData()
|
||||
);
|
||||
|
||||
lt.it.shouldBeAllowedWhenCalledByUser(CURRENT_USER, 'POST', '/api/users/logout');
|
||||
|
||||
|
|
|
@ -144,7 +144,8 @@ describe('loopback.token(options)', function() {
|
|||
var app = createTestApp(
|
||||
this.token,
|
||||
{token: {searchDefaultTokenKeys: false}},
|
||||
done);
|
||||
done
|
||||
);
|
||||
var agent = request.agent(app);
|
||||
|
||||
// Set the token cookie
|
||||
|
@ -604,7 +605,8 @@ describe('AccessToken', function() {
|
|||
param: function(name) { return this._params[name]; },
|
||||
header: function(name) { return this.headers[name]; },
|
||||
},
|
||||
opts);
|
||||
opts
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -223,7 +223,8 @@ describe('app', function() {
|
|||
expect(steps).to.eql(['/scope', '/scope/item']);
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('scopes middleware to a regex path', function(done) {
|
||||
|
@ -238,7 +239,8 @@ describe('app', function() {
|
|||
expect(steps).to.eql(['/a', '/b']);
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('scopes middleware to a list of scopes', function(done) {
|
||||
|
@ -253,7 +255,8 @@ describe('app', function() {
|
|||
expect(steps).to.eql(['/a', '/b', '/scope']);
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('sets req.url to a sub-path', function(done) {
|
||||
|
@ -537,7 +540,8 @@ describe('app', function() {
|
|||
{
|
||||
phase: 'initial',
|
||||
paths: ['/scope', /^\/(a|b)/],
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
async.eachSeries(
|
||||
['/', '/a', '/b', '/c', '/scope', '/other'],
|
||||
|
@ -548,7 +552,8 @@ describe('app', function() {
|
|||
expect(steps).to.eql(['/a', '/b', '/scope']);
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -918,17 +923,15 @@ describe('app', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('forwards to http.Server.listen when the single arg is not a function',
|
||||
function(done) {
|
||||
var app = loopback();
|
||||
app.set('port', 1);
|
||||
app.listen(0).on('listening', function() {
|
||||
expect(app.get('port'), 'port') .to.not.equal(0).and.not.equal(1);
|
||||
it('forwards to http.Server.listen when the single arg is not a function', function(done) {
|
||||
var app = loopback();
|
||||
app.set('port', 1);
|
||||
app.listen(0).on('listening', function() {
|
||||
expect(app.get('port'), 'port') .to.not.equal(0).and.not.equal(1);
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('uses app config when no parameter is supplied', function(done) {
|
||||
var app = loopback();
|
||||
|
|
|
@ -222,7 +222,8 @@ describe('Change', function() {
|
|||
change = ch;
|
||||
|
||||
done(err);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should create a new change with the correct revision', function(done) {
|
||||
|
|
|
@ -215,7 +215,8 @@ describe('OptionsFromRemotingContext', function() {
|
|||
Category = app.registry.createModel(
|
||||
'Category',
|
||||
{name: String},
|
||||
{forceId: false, replaceOnPUT: true});
|
||||
{forceId: false, replaceOnPUT: true}
|
||||
);
|
||||
|
||||
app.model(Category, {dataSource: 'db'});
|
||||
// This is a shortcut for creating CategoryProduct "through" model
|
||||
|
@ -287,7 +288,8 @@ describe('OptionsFromRemotingContext', function() {
|
|||
Category = app.registry.createModel(
|
||||
'Category',
|
||||
{name: String},
|
||||
{forceId: false, replaceOnPUT: true});
|
||||
{forceId: false, replaceOnPUT: true}
|
||||
);
|
||||
|
||||
app.model(Category, {dataSource: 'db'});
|
||||
Category.hasOne(Product);
|
||||
|
@ -331,7 +333,8 @@ describe('OptionsFromRemotingContext', function() {
|
|||
Category = app.registry.createModel(
|
||||
'Category',
|
||||
{name: String},
|
||||
{forceId: false, replaceOnPUT: true});
|
||||
{forceId: false, replaceOnPUT: true}
|
||||
);
|
||||
|
||||
app.model(Category, {dataSource: 'db'});
|
||||
Category.belongsTo(Product);
|
||||
|
@ -361,7 +364,8 @@ describe('OptionsFromRemotingContext', function() {
|
|||
Product = app.registry.createModel(
|
||||
'Product',
|
||||
{name: String},
|
||||
{forceId: false, replaceOnPUT: true});
|
||||
{forceId: false, replaceOnPUT: true}
|
||||
);
|
||||
|
||||
Product.createOptionsFromRemotingContext = function(ctx) {
|
||||
return {injectedFrom: 'Product'};
|
||||
|
|
|
@ -11,7 +11,8 @@ var request = require('supertest');
|
|||
describe('hidden properties', function() {
|
||||
beforeEach(function(done) {
|
||||
var app = this.app = loopback();
|
||||
var Product = this.Product = loopback.PersistedModel.extend('product',
|
||||
var Product = this.Product = loopback.PersistedModel.extend(
|
||||
'product',
|
||||
{},
|
||||
{hidden: ['secret']}
|
||||
);
|
||||
|
|
|
@ -29,7 +29,8 @@ describe('loopback application', function() {
|
|||
expect(res).to.match(/\nX$/);
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
function setupAppWithStreamingMethod() {
|
||||
|
|
|
@ -285,7 +285,8 @@ describe('Multiple users with custom principalType', function() {
|
|||
describe('role.users()', function() {
|
||||
it('returns users when using custom user principalType', function() {
|
||||
return userRole.principals.create(
|
||||
{principalType: OneUser.modelName, principalId: userFromOneModel.id})
|
||||
{principalType: OneUser.modelName, principalId: userFromOneModel.id}
|
||||
)
|
||||
.then(function() {
|
||||
return userRole.users({where: {principalType: OneUser.modelName}});
|
||||
})
|
||||
|
@ -297,7 +298,8 @@ describe('Multiple users with custom principalType', function() {
|
|||
|
||||
it('returns empty array when using invalid principalType', function() {
|
||||
return userRole.principals.create(
|
||||
{principalType: 'invalidModelName', principalId: userFromOneModel.id})
|
||||
{principalType: 'invalidModelName', principalId: userFromOneModel.id}
|
||||
)
|
||||
.then(function() {
|
||||
return userRole.users({where: {principalType: 'invalidModelName'}});
|
||||
})
|
||||
|
@ -310,24 +312,22 @@ describe('Multiple users with custom principalType', function() {
|
|||
describe('principal.user()', function() {
|
||||
it('returns the correct user instance', function() {
|
||||
return userRole.principals.create(
|
||||
{principalType: OneUser.modelName, principalId: userFromOneModel.id})
|
||||
.then(function(principal) {
|
||||
return principal.user();
|
||||
})
|
||||
.then(function(user) {
|
||||
expect(user).to.have.property('id', userFromOneModel.id);
|
||||
});
|
||||
{principalType: OneUser.modelName, principalId: userFromOneModel.id}
|
||||
).then(function(principal) {
|
||||
return principal.user();
|
||||
}).then(function(user) {
|
||||
expect(user).to.have.property('id', userFromOneModel.id);
|
||||
});
|
||||
});
|
||||
|
||||
it('returns null when created with invalid principalType', function() {
|
||||
return userRole.principals.create(
|
||||
{principalType: 'invalidModelName', principalId: userFromOneModel.id})
|
||||
.then(function(principal) {
|
||||
return principal.user();
|
||||
})
|
||||
.then(function(user) {
|
||||
expect(user).to.not.exist();
|
||||
});
|
||||
{principalType: 'invalidModelName', principalId: userFromOneModel.id}
|
||||
).then(function(principal) {
|
||||
return principal.user();
|
||||
}).then(function(user) {
|
||||
expect(user).to.not.exist();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -346,14 +346,14 @@ describe('Multiple users with custom principalType', function() {
|
|||
|
||||
it('supports getRoles()', function() {
|
||||
return Role.getRoles(
|
||||
userOneBaseContext)
|
||||
.then(function(roles) {
|
||||
expect(roles).to.eql([
|
||||
Role.AUTHENTICATED,
|
||||
Role.EVERYONE,
|
||||
userRole.id,
|
||||
]);
|
||||
});
|
||||
userOneBaseContext
|
||||
).then(function(roles) {
|
||||
expect(roles).to.eql([
|
||||
Role.AUTHENTICATED,
|
||||
Role.EVERYONE,
|
||||
userRole.id,
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -72,8 +72,7 @@ describe('relations - integration', function() {
|
|||
reader.team(test.team);
|
||||
reader.save(done);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
|
@ -784,7 +783,8 @@ describe('relations - integration', function() {
|
|||
|
||||
describe('embedsOne', function() {
|
||||
before(function defineGroupAndPosterModels() {
|
||||
var group = app.registry.createModel('group',
|
||||
var group = app.registry.createModel(
|
||||
'group',
|
||||
{name: 'string'},
|
||||
{plural: 'groups'}
|
||||
);
|
||||
|
|
|
@ -16,8 +16,7 @@ describe('remoting coercion', function() {
|
|||
|
||||
var TestModel = app.registry.createModel('TestModel',
|
||||
{},
|
||||
{base: 'Model'}
|
||||
);
|
||||
{base: 'Model'});
|
||||
app.model(TestModel, {public: true});
|
||||
|
||||
TestModel.test = function(inst, cb) {
|
||||
|
|
|
@ -192,7 +192,8 @@ describe('Replication over REST', function() {
|
|||
var conflict = new LocalConflict(
|
||||
conflictedCarId,
|
||||
LocalCar,
|
||||
RemoteCar);
|
||||
RemoteCar
|
||||
);
|
||||
conflict.resolveUsingSource(expectHttpError(401, done));
|
||||
});
|
||||
|
||||
|
@ -201,7 +202,8 @@ describe('Replication over REST', function() {
|
|||
var conflict = new RemoteConflict(
|
||||
conflictedCarId,
|
||||
RemoteCar,
|
||||
LocalCar);
|
||||
LocalCar
|
||||
);
|
||||
conflict.resolveUsingSource(expectHttpError(401, done));
|
||||
});
|
||||
});
|
||||
|
@ -216,7 +218,8 @@ describe('Replication over REST', function() {
|
|||
var conflict = new LocalConflict(
|
||||
conflictedCarId,
|
||||
LocalCar,
|
||||
RemoteCar);
|
||||
RemoteCar
|
||||
);
|
||||
conflict.resolveUsingSource(done);
|
||||
});
|
||||
|
||||
|
@ -225,7 +228,8 @@ describe('Replication over REST', function() {
|
|||
var conflict = new RemoteConflict(
|
||||
conflictedCarId,
|
||||
RemoteCar,
|
||||
LocalCar);
|
||||
LocalCar
|
||||
);
|
||||
conflict.resolveUsingSource(expectHttpError(401, done));
|
||||
});
|
||||
});
|
||||
|
@ -403,7 +407,8 @@ describe('Replication over REST', function() {
|
|||
LocalUser.updateAll(
|
||||
{id: aliceId},
|
||||
{fullname: 'Alice Smith'},
|
||||
done);
|
||||
done
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -606,7 +611,8 @@ describe('Replication over REST', function() {
|
|||
serverCars = cars.map(carToString);
|
||||
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
], done);
|
||||
}
|
||||
|
@ -625,7 +631,8 @@ describe('Replication over REST', function() {
|
|||
clientCars = cars.map(carToString);
|
||||
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
], done);
|
||||
}
|
||||
|
|
|
@ -30,14 +30,16 @@ describe('Replication / Change APIs', function() {
|
|||
SourceModel = this.SourceModel = PersistedModel.extend(
|
||||
'SourceModel-' + tid,
|
||||
{id: {id: true, type: String, defaultFn: 'guid'}},
|
||||
{trackChanges: true});
|
||||
{trackChanges: true}
|
||||
);
|
||||
|
||||
SourceModel.attachTo(dataSource);
|
||||
|
||||
TargetModel = this.TargetModel = PersistedModel.extend(
|
||||
'TargetModel-' + tid,
|
||||
{id: {id: true, type: String, defaultFn: 'guid'}},
|
||||
{trackChanges: true});
|
||||
{trackChanges: true}
|
||||
);
|
||||
|
||||
// NOTE(bajtos) At the moment, all models share the same Checkpoint
|
||||
// model. This causes the in-process replication to work differently
|
||||
|
@ -83,7 +85,8 @@ describe('Replication / Change APIs', function() {
|
|||
Model = this.Model = PersistedModel.extend(
|
||||
'Model-' + tid,
|
||||
{id: {id: true, type: String, defaultFn: 'guid'}},
|
||||
{trackChanges: true, changeCleanupInterval: -1});
|
||||
{trackChanges: true, changeCleanupInterval: -1}
|
||||
);
|
||||
|
||||
Model.attachTo(dataSource);
|
||||
});
|
||||
|
@ -102,7 +105,8 @@ describe('Replication / Change APIs', function() {
|
|||
Model = this.Model = PersistedModel.extend(
|
||||
'Model-' + tid,
|
||||
{id: {id: true, type: String, defaultFn: 'guid'}},
|
||||
{trackChanges: true, changeCleanupInterval: 10000});
|
||||
{trackChanges: true, changeCleanupInterval: 10000}
|
||||
);
|
||||
|
||||
Model.attachTo(dataSource);
|
||||
});
|
||||
|
@ -538,7 +542,8 @@ describe('Replication / Change APIs', function() {
|
|||
});
|
||||
|
||||
cb();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
], done);
|
||||
|
||||
|
@ -581,7 +586,8 @@ describe('Replication / Change APIs', function() {
|
|||
expect(changes).to.have.length(0);
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
},
|
||||
], done);
|
||||
|
@ -603,7 +609,8 @@ describe('Replication / Change APIs', function() {
|
|||
TargetModel.modelName,
|
||||
'1',
|
||||
{name: '3rd-party'},
|
||||
cb);
|
||||
cb
|
||||
);
|
||||
} else {
|
||||
// 2.x connectors require `options`
|
||||
connector.updateAttributes(
|
||||
|
@ -611,7 +618,8 @@ describe('Replication / Change APIs', function() {
|
|||
'1',
|
||||
{name: '3rd-party'},
|
||||
{}, // options
|
||||
cb);
|
||||
cb
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -625,7 +633,8 @@ describe('Replication / Change APIs', function() {
|
|||
|
||||
// resolve the conflict using ours
|
||||
conflicts[0].resolve(next);
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
replicateExpectingSuccess(),
|
||||
|
@ -645,14 +654,16 @@ describe('Replication / Change APIs', function() {
|
|||
connector.create(
|
||||
TargetModel.modelName,
|
||||
{id: '1', name: '3rd-party'},
|
||||
cb);
|
||||
cb
|
||||
);
|
||||
} else {
|
||||
// 2.x connectors require `options`
|
||||
connector.create(
|
||||
TargetModel.modelName,
|
||||
{id: '1', name: '3rd-party'},
|
||||
{}, // options
|
||||
cb);
|
||||
cb
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -666,7 +677,8 @@ describe('Replication / Change APIs', function() {
|
|||
|
||||
// resolve the conflict using ours
|
||||
conflicts[0].resolve(next);
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
replicateExpectingSuccess(),
|
||||
|
@ -689,7 +701,8 @@ describe('Replication / Change APIs', function() {
|
|||
TargetModel.modelName,
|
||||
'1',
|
||||
{name: '3rd-party'},
|
||||
cb);
|
||||
cb
|
||||
);
|
||||
} else {
|
||||
// 2.x connectors require `options`
|
||||
connector.updateAttributes(
|
||||
|
@ -697,7 +710,8 @@ describe('Replication / Change APIs', function() {
|
|||
'1',
|
||||
{name: '3rd-party'},
|
||||
{}, // options
|
||||
cb);
|
||||
cb
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -711,7 +725,8 @@ describe('Replication / Change APIs', function() {
|
|||
|
||||
// resolve the conflict using ours
|
||||
conflicts[0].resolve(next);
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
replicateExpectingSuccess(),
|
||||
|
@ -733,14 +748,16 @@ describe('Replication / Change APIs', function() {
|
|||
connector.destroy(
|
||||
TargetModel.modelName,
|
||||
'1',
|
||||
cb);
|
||||
cb
|
||||
);
|
||||
} else {
|
||||
// 2.x connectors require `options`
|
||||
connector.destroy(
|
||||
TargetModel.modelName,
|
||||
'1',
|
||||
{}, // options
|
||||
cb);
|
||||
cb
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1061,7 +1078,8 @@ describe('Replication / Change APIs', function() {
|
|||
function(err) {
|
||||
if (err) return done(err);
|
||||
assertChangeRecordedForId(inst.id, done);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1098,7 +1116,8 @@ describe('Replication / Change APIs', function() {
|
|||
if (err) return done(err);
|
||||
|
||||
assertChangeRecordedForId(inst.id, done);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('detects "deleteById"', function(done) {
|
||||
|
@ -1134,7 +1153,8 @@ describe('Replication / Change APIs', function() {
|
|||
if (err) return done(err);
|
||||
|
||||
assertChangeRecordedForId(inst.id, done);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1229,7 +1249,8 @@ describe('Replication / Change APIs', function() {
|
|||
AnotherModel = this.AnotherModel = PersistedModel.extend(
|
||||
'AnotherModel-' + tid,
|
||||
{id: {id: true, type: String, defaultFn: 'guid'}},
|
||||
{trackChanges: true});
|
||||
{trackChanges: true}
|
||||
);
|
||||
|
||||
// NOTE(bajtos) At the moment, all models share the same Checkpoint
|
||||
// model. This causes the in-process replication to work differently
|
||||
|
@ -1388,7 +1409,8 @@ describe('Replication / Change APIs', function() {
|
|||
function resolveUsingOurs(conflict, cb) {
|
||||
conflict.resolveUsingSource(cb);
|
||||
},
|
||||
done);
|
||||
done
|
||||
);
|
||||
});
|
||||
|
||||
it('handles UPDATE conflict resolved using "theirs"', function(done) {
|
||||
|
@ -1399,7 +1421,8 @@ describe('Replication / Change APIs', function() {
|
|||
.to.equal(ClientB.modelName);
|
||||
conflict.resolveUsingTarget(cb);
|
||||
},
|
||||
done);
|
||||
done
|
||||
);
|
||||
});
|
||||
|
||||
it('handles UPDATE conflict resolved manually', function(done) {
|
||||
|
@ -1407,7 +1430,8 @@ describe('Replication / Change APIs', function() {
|
|||
function resolveManually(conflict, cb) {
|
||||
conflict.resolveManually({name: 'manual'}, cb);
|
||||
},
|
||||
done);
|
||||
done
|
||||
);
|
||||
});
|
||||
|
||||
it('handles DELETE conflict resolved using "ours"', function(done) {
|
||||
|
@ -1415,7 +1439,8 @@ describe('Replication / Change APIs', function() {
|
|||
function resolveUsingOurs(conflict, cb) {
|
||||
conflict.resolveUsingSource(cb);
|
||||
},
|
||||
done);
|
||||
done
|
||||
);
|
||||
});
|
||||
|
||||
it('handles DELETE conflict resolved using "theirs"', function(done) {
|
||||
|
@ -1426,7 +1451,8 @@ describe('Replication / Change APIs', function() {
|
|||
.to.equal(ClientB.modelName);
|
||||
conflict.resolveUsingTarget(cb);
|
||||
},
|
||||
done);
|
||||
done
|
||||
);
|
||||
});
|
||||
|
||||
it('handles DELETE conflict resolved as manual delete', function(done) {
|
||||
|
@ -1434,7 +1460,8 @@ describe('Replication / Change APIs', function() {
|
|||
function resolveManually(conflict, cb) {
|
||||
conflict.resolveManually(null, cb);
|
||||
},
|
||||
done);
|
||||
done
|
||||
);
|
||||
});
|
||||
|
||||
it('handles DELETE conflict resolved manually', function(done) {
|
||||
|
@ -1442,7 +1469,8 @@ describe('Replication / Change APIs', function() {
|
|||
function resolveManually(conflict, cb) {
|
||||
conflict.resolveManually({name: 'manual'}, cb);
|
||||
},
|
||||
done);
|
||||
done
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1585,7 +1613,8 @@ describe('Replication / Change APIs', function() {
|
|||
OptionsSourceModel = PersistedModel.extend(
|
||||
'OptionsSourceModel-' + tid,
|
||||
{id: {id: true, type: String, defaultFn: 'guid'}},
|
||||
{trackChanges: true});
|
||||
{trackChanges: true}
|
||||
);
|
||||
|
||||
OptionsSourceModel.attachTo(dataSource);
|
||||
|
||||
|
@ -1631,8 +1660,7 @@ describe('Replication / Change APIs', function() {
|
|||
expect(syncPropertyExists).to.eql(true);
|
||||
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1670,14 +1698,16 @@ describe('Replication / Change APIs', function() {
|
|||
SourceModel = this.SourceModel = PersistedModel.extend(
|
||||
'SourceModel-' + tid,
|
||||
{id: {id: true, type: String, defaultFn: 'guid'}},
|
||||
{trackChanges: true, replicationChunkSize: 1});
|
||||
{trackChanges: true, replicationChunkSize: 1}
|
||||
);
|
||||
|
||||
SourceModel.attachTo(dataSource);
|
||||
|
||||
TargetModel = this.TargetModel = PersistedModel.extend(
|
||||
'TargetModel-' + tid,
|
||||
{id: {id: true, type: String, defaultFn: 'guid'}},
|
||||
{trackChanges: true, replicationChunkSize: 1});
|
||||
{trackChanges: true, replicationChunkSize: 1}
|
||||
);
|
||||
|
||||
var TargetChange = TargetModel.Change;
|
||||
TargetChange.Checkpoint = loopback.Checkpoint.extend('TargetCheckpoint');
|
||||
|
@ -1716,14 +1746,16 @@ describe('Replication / Change APIs', function() {
|
|||
SourceModel = this.SourceModel = PersistedModel.extend(
|
||||
'SourceModel-' + tid,
|
||||
{id: {id: true, type: String, defaultFn: 'guid'}},
|
||||
{trackChanges: true});
|
||||
{trackChanges: true}
|
||||
);
|
||||
|
||||
SourceModel.attachTo(dataSource);
|
||||
|
||||
TargetModel = this.TargetModel = PersistedModel.extend(
|
||||
'TargetModel-' + tid,
|
||||
{id: {id: true, type: String, defaultFn: 'guid'}},
|
||||
{trackChanges: true});
|
||||
{trackChanges: true}
|
||||
);
|
||||
|
||||
var TargetChange = TargetModel.Change;
|
||||
TargetChange.Checkpoint = loopback.Checkpoint.extend('TargetCheckpoint');
|
||||
|
@ -1928,7 +1960,8 @@ describe('Replication / Change APIs with custom change properties', function() {
|
|||
{
|
||||
trackChanges: true,
|
||||
additionalChangeModelProperties: {customProperty: {type: 'string'}},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
SourceModel.createChangeFilter = function(since, modelFilter) {
|
||||
const filter = this.base.createChangeFilter.apply(this, arguments);
|
||||
|
@ -1958,7 +1991,8 @@ describe('Replication / Change APIs with custom change properties', function() {
|
|||
{
|
||||
trackChanges: true,
|
||||
additionalChangeModelProperties: {customProperty: {type: 'string'}},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
var ChangeModelForTarget = TargetModel.Change;
|
||||
ChangeModelForTarget.Checkpoint = loopback.Checkpoint.extend('TargetCheckpoint');
|
||||
|
@ -1997,7 +2031,8 @@ describe('Replication / Change APIs with custom change properties', function() {
|
|||
},
|
||||
});
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('query returns the matching changes', function(done) {
|
||||
|
@ -2008,7 +2043,8 @@ describe('Replication / Change APIs with custom change properties', function() {
|
|||
expect(changes).to.have.length(1);
|
||||
expect(changes[0]).to.have.property('customProperty', '123');
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
function givenSomeSourceModelInstances(done) {
|
||||
|
|
|
@ -55,7 +55,8 @@ describe('role-mapping model', function() {
|
|||
expect(user.id).to.equal(oneUser.id);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('supports .user() returning a promise', function() {
|
||||
|
@ -78,7 +79,8 @@ describe('role-mapping model', function() {
|
|||
expect(app.id).to.equal(anApp.id);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('supports .application() returning a promise', function() {
|
||||
|
@ -101,7 +103,8 @@ describe('role-mapping model', function() {
|
|||
expect(role.id).to.equal(aRole.id);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('supports .childRole() returning a promise', function() {
|
||||
|
|
|
@ -92,7 +92,8 @@ describe('role model', function() {
|
|||
});
|
||||
},
|
||||
], done);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -223,7 +224,8 @@ describe('role model', function() {
|
|||
// but the matchin role object instead
|
||||
assert(!!inRole);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function(next) {
|
||||
Role.isInRole(
|
||||
|
@ -233,7 +235,8 @@ describe('role model', function() {
|
|||
if (err) return next(err);
|
||||
assert(!inRole);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function(next) {
|
||||
Role.isInRole(
|
||||
|
@ -243,7 +246,8 @@ describe('role model', function() {
|
|||
if (err) return next(err);
|
||||
assert(!inRole);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function(next) {
|
||||
Role.getRoles(
|
||||
|
@ -256,7 +260,8 @@ describe('role model', function() {
|
|||
role.id,
|
||||
]);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function(next) {
|
||||
Role.getRoles(
|
||||
|
@ -270,7 +275,8 @@ describe('role model', function() {
|
|||
role.name,
|
||||
]);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function(next) {
|
||||
Role.getRoles(
|
||||
|
@ -282,7 +288,8 @@ describe('role model', function() {
|
|||
Role.EVERYONE,
|
||||
]);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function(next) {
|
||||
Role.getRoles(
|
||||
|
@ -294,7 +301,8 @@ describe('role model', function() {
|
|||
Role.EVERYONE,
|
||||
]);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function(next) {
|
||||
Role.getRoles(
|
||||
|
@ -306,7 +314,8 @@ describe('role model', function() {
|
|||
Role.EVERYONE,
|
||||
]);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
], done);
|
||||
});
|
||||
|
@ -391,7 +400,8 @@ describe('role model', function() {
|
|||
if (err) return next(err);
|
||||
assert(!!inRole);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function(next) {
|
||||
Role.isInRole(
|
||||
|
@ -401,7 +411,8 @@ describe('role model', function() {
|
|||
if (err) return next(err);
|
||||
assert(!inRole);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function(next) {
|
||||
Role.getRoles(
|
||||
|
@ -414,7 +425,8 @@ describe('role model', function() {
|
|||
role.id,
|
||||
]);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
], done);
|
||||
});
|
||||
|
@ -457,7 +469,8 @@ describe('role model', function() {
|
|||
if (err) return next(err);
|
||||
assert(yes);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function(next) {
|
||||
Role.isInRole(
|
||||
|
@ -467,7 +480,8 @@ describe('role model', function() {
|
|||
if (err) next(err);
|
||||
assert(yes);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function(next) {
|
||||
Role.isInRole(
|
||||
|
@ -477,7 +491,8 @@ describe('role model', function() {
|
|||
if (err) next(err);
|
||||
assert(!yes);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function(next) {
|
||||
Role.isInRole(
|
||||
|
@ -487,7 +502,8 @@ describe('role model', function() {
|
|||
if (err) return next(err);
|
||||
assert(!yes);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function(next) {
|
||||
Role.isInRole(
|
||||
|
@ -497,7 +513,8 @@ describe('role model', function() {
|
|||
if (err) return next(err);
|
||||
assert(yes);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function(next) {
|
||||
Role.isInRole(
|
||||
|
@ -507,7 +524,8 @@ describe('role model', function() {
|
|||
if (err) return next(err);
|
||||
assert(yes);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function(next) {
|
||||
Role.isInRole(
|
||||
|
@ -517,7 +535,8 @@ describe('role model', function() {
|
|||
if (err) return next(err);
|
||||
assert(yes);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function(next) {
|
||||
Album.create({name: 'Album 1', userId: user.id}, function(err, album1) {
|
||||
|
@ -1073,7 +1092,8 @@ describe('role model', function() {
|
|||
function(err, p) {
|
||||
if (err) return callback(err);
|
||||
callback(p);
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
roles[1].principals.create(
|
||||
|
@ -1081,7 +1101,8 @@ describe('role model', function() {
|
|||
function(err, p) {
|
||||
if (err) return callback(err);
|
||||
callback(p);
|
||||
});
|
||||
}
|
||||
);
|
||||
}],
|
||||
function(err, principles) {
|
||||
next(null, models, roles, principles);
|
||||
|
|
|
@ -88,7 +88,8 @@ describe('User.password', () => {
|
|||
},
|
||||
function onError(err) {
|
||||
expect(err.message).to.match(/Invalid use.*options.setPassword/);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
function givenAppWithRejectionEnabled() {
|
||||
|
@ -237,6 +238,7 @@ describe('User.password', () => {
|
|||
function patchNameAndPasswordDirectly() {
|
||||
return testUser.patchAttributes(
|
||||
{password: 'new-pass', name: 'New Name'},
|
||||
{setPassword: true});
|
||||
{setPassword: true}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -147,7 +147,8 @@ describe('User', function() {
|
|||
expect(err.statusCode).to.equal(422);
|
||||
expect(err.details.context).to.equal(User.modelName);
|
||||
expect(err.details.codes.email).to.deep.equal(['presence']);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('fails when the required email is missing (case-sensitivity off)', () => {
|
||||
|
@ -160,7 +161,8 @@ describe('User', function() {
|
|||
expect(err.statusCode).to.equal(422);
|
||||
expect(err.details.context).to.equal(User.modelName);
|
||||
expect(err.details.codes.email).to.deep.equal(['presence']);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// will change in future versions where password will be optional by default
|
||||
|
@ -547,7 +549,8 @@ describe('User', function() {
|
|||
code: 'PASSWORD_TOO_LONG',
|
||||
statusCode: 422,
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('rejects setPassword when new password is longer than 72 chars', function() {
|
||||
|
@ -566,7 +569,8 @@ describe('User', function() {
|
|||
code: 'PASSWORD_TOO_LONG',
|
||||
statusCode: 422,
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1463,7 +1467,8 @@ describe('User', function() {
|
|||
code: 'INVALID_PASSWORD',
|
||||
statusCode: 400,
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('fails with 401 for unknown user id', () => {
|
||||
|
@ -1478,7 +1483,8 @@ describe('User', function() {
|
|||
code: 'USER_NOT_FOUND',
|
||||
statusCode: 401,
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('forwards the "options" argument', () => {
|
||||
|
@ -1565,7 +1571,8 @@ describe('User', function() {
|
|||
code: 'USER_NOT_FOUND',
|
||||
statusCode: 401,
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('forwards the "options" argument', () => {
|
||||
|
@ -2601,7 +2608,8 @@ describe('User', function() {
|
|||
function(err, userInstance) {
|
||||
if (err) return done(err);
|
||||
assertNoAccessTokens(done);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('invalidates sessions after `replaceAttributes`', function(done) {
|
||||
|
@ -2718,7 +2726,8 @@ describe('User', function() {
|
|||
if (err) return next(err);
|
||||
userPartial = partialInstance;
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function loginPartiallUser(next) {
|
||||
User.login({email: 'partial@example.com', password: 'pass1'}, function(err, ats) {
|
||||
|
@ -2733,7 +2742,8 @@ describe('User', function() {
|
|||
function(err, info) {
|
||||
if (err) return next(err);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function verifyTokensOfPartialUser(next) {
|
||||
AccessToken.find({where: {userId: userPartial.pk}}, function(err, tokens1) {
|
||||
|
@ -2777,8 +2787,10 @@ describe('User', function() {
|
|||
if (err) return next(err);
|
||||
next();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
function(next) {
|
||||
user2.updateAttribute('email', 'user2Update@b.com', function(err, userInstance) {
|
||||
|
@ -2816,7 +2828,8 @@ describe('User', function() {
|
|||
if (err) return next(err);
|
||||
userSpecial = specialInstance;
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function loginSpecialUser(next) {
|
||||
User.login({email: 'special@example.com', password: 'pass1'}, function(err, ats) {
|
||||
|
@ -2830,7 +2843,8 @@ describe('User', function() {
|
|||
{email: 'superspecial@example.com'}, function(err, info) {
|
||||
if (err) return next(err);
|
||||
next();
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
function verifyTokensOfSpecialUser(next) {
|
||||
AccessToken.find({where: {userId: userSpecial.pk}}, function(err, tokens1) {
|
||||
|
|
Loading…
Reference in New Issue