Moved tests
This commit is contained in:
42
tests/test-password.js
Normal file
42
tests/test-password.js
Normal file
@@ -0,0 +1,42 @@
|
||||
const config = require('../settings/config.js');
|
||||
require('app-module-path').addPath(config.BASE_DIR);
|
||||
require('app-module-path').addPath(config.UTILS_DIR);
|
||||
require('app-module-path').addPath(config.CONTROLLERS_DIR);
|
||||
|
||||
const model = require('model');
|
||||
const User = require('auth/models');
|
||||
const log = require('log');
|
||||
|
||||
model.reinitialize(() => {
|
||||
|
||||
log.debug('Database reinitialized');
|
||||
|
||||
let user = new User();
|
||||
user.email = "toto";
|
||||
user.password = "tata";
|
||||
user.resources = 23;
|
||||
user.project_id = 42;
|
||||
user.save((err, u) => {
|
||||
|
||||
log.debug('New user created');
|
||||
|
||||
// Test password
|
||||
User.getById(1, (err, user) => {
|
||||
if (model.PasswordField.testSync("tata", user.password)) {
|
||||
log.debug("Password authentication succeed");
|
||||
} else {
|
||||
log.error("Password should have succeeded but failed");
|
||||
}
|
||||
|
||||
if (!model.PasswordField.testSync("toto", user.password)) {
|
||||
log.debug("Password authentication failed as it was supposed to");
|
||||
} else {
|
||||
log.error("Password should have failed but succeded");
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user