Add displayName to create user and activate routes

This commit is contained in:
girish@cloudron.io
2016-01-19 23:34:49 -08:00
parent 67b94c7fde
commit ee705eb979
7 changed files with 39 additions and 20 deletions
+6 -4
View File
@@ -18,13 +18,15 @@ var database = require('../database.js'),
var USER_0 = {
username: 'foobar0',
password: 'password0',
email: 'foo0@bar.com'
email: 'foo0@bar.com',
displayName: 'Bob bobson'
};
var USER_1 = {
username: 'foobar1',
password: 'password1',
email: 'foo1@bar.com'
email: 'foo1@bar.com',
displayName: 'Jesus'
};
function setup(done) {
@@ -32,8 +34,8 @@ function setup(done) {
database.initialize.bind(null),
database._clear.bind(null),
ldapServer.start.bind(null),
user.create.bind(null, USER_0.username, USER_0.password, USER_0.email, true, null, false),
user.create.bind(null, USER_1.username, USER_1.password, USER_1.email, false, USER_0, false)
user.create.bind(null, USER_0.username, USER_0.password, USER_0.email, USER_0.displayName, true, null, false),
user.create.bind(null, USER_1.username, USER_1.password, USER_1.email, USER_0.displayName, false, USER_0, false)
], done);
}
+7 -6
View File
@@ -20,6 +20,7 @@ var EMAIL_NEW = 'nobodynew@no.body';
var PASSWORD = 'foobar';
var NEW_PASSWORD = 'somenewpassword';
var IS_ADMIN = true;
var DISPLAY_NAME = 'Nobody cares';
var userObject = null;
function cleanupUsers(done) {
@@ -30,7 +31,7 @@ function cleanupUsers(done) {
}
function createUser(done) {
user.create(USERNAME, PASSWORD, EMAIL, IS_ADMIN, null /* invitor */, false, function (error, result) {
user.create(USERNAME, PASSWORD, EMAIL, DISPLAY_NAME, IS_ADMIN, null /* invitor */, false, function (error, result) {
expect(error).to.not.be.ok();
expect(result).to.be.ok();
@@ -75,7 +76,7 @@ describe('User', function () {
after(cleanupUsers);
it('succeeds and attempts to send invite', function (done) {
user.create(USERNAME, PASSWORD, EMAIL, IS_ADMIN, null /* invitor */, true, function (error, result) {
user.create(USERNAME, PASSWORD, EMAIL, DISPLAY_NAME, IS_ADMIN, null /* invitor */, true, function (error, result) {
expect(error).not.to.be.ok();
expect(result).to.be.ok();
expect(result.username).to.equal(USERNAME);
@@ -110,7 +111,7 @@ describe('User', function () {
});
it('fails because user exists', function (done) {
user.create(USERNAME, PASSWORD, EMAIL, IS_ADMIN, null /* invitor */, false, function (error, result) {
user.create(USERNAME, PASSWORD, EMAIL, DISPLAY_NAME, IS_ADMIN, null /* invitor */, false, function (error, result) {
expect(error).to.be.ok();
expect(result).not.to.be.ok();
expect(error.reason).to.equal(UserError.ALREADY_EXISTS);
@@ -120,7 +121,7 @@ describe('User', function () {
});
it('fails because password is empty', function (done) {
user.create(USERNAME, '', EMAIL, IS_ADMIN, null /* invitor */, false, function (error, result) {
user.create(USERNAME, '', EMAIL, DISPLAY_NAME, IS_ADMIN, null /* invitor */, false, function (error, result) {
expect(error).to.be.ok();
expect(result).not.to.be.ok();
expect(error.reason).to.equal(UserError.BAD_PASSWORD);
@@ -330,7 +331,7 @@ describe('User', function () {
email: 'some@thi.ng'
};
user.create(user1.username, user1.password, user1.email, false, { username: USERNAME, email: EMAIL } /* invitor */, false, function (error, result) {
user.create(user1.username, user1.password, user1.email, DISPLAY_NAME, false, { username: USERNAME, email: EMAIL } /* invitor */, false, function (error, result) {
expect(error).to.not.be.ok();
expect(result).to.be.ok();
@@ -372,7 +373,7 @@ describe('User', function () {
email: 'some@thi.ng'
};
user.create(user1.username, user1.password, user1.email, false, { username: USERNAME, email: EMAIL } /* invitor */, false, function (error, result) {
user.create(user1.username, user1.password, user1.email, DISPLAY_NAME, false, { username: USERNAME, email: EMAIL } /* invitor */, false, function (error, result) {
expect(error).to.eql(null);
expect(result).to.be.ok();