Finish UsersError removal
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('async'),
|
||||
BoxError = require('../boxerror.js'),
|
||||
database = require('../database.js'),
|
||||
constants = require('../constants.js'),
|
||||
expect = require('expect.js'),
|
||||
@@ -19,8 +20,7 @@ var async = require('async'),
|
||||
mailer = require('../mailer.js'),
|
||||
settings = require('../settings.js'),
|
||||
userdb = require('../userdb.js'),
|
||||
users = require('../users.js'),
|
||||
UsersError = users.UsersError;
|
||||
users = require('../users.js');
|
||||
|
||||
var USERNAME = 'noBody';
|
||||
var USERNAME_NEW = 'noBodyNew';
|
||||
@@ -115,7 +115,7 @@ describe('User', function () {
|
||||
users.create(USERNAME, 'Fo$%23', EMAIL, DISPLAY_NAME, { }, AUDIT_SOURCE, function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.equal(UsersError.BAD_FIELD);
|
||||
expect(error.reason).to.equal(BoxError.BAD_FIELD);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -125,7 +125,7 @@ describe('User', function () {
|
||||
users.create('admin', PASSWORD, EMAIL, DISPLAY_NAME, { }, AUDIT_SOURCE, function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.equal(UsersError.BAD_FIELD);
|
||||
expect(error.reason).to.equal(BoxError.BAD_FIELD);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -135,7 +135,7 @@ describe('User', function () {
|
||||
users.create('moo+daemon', PASSWORD, EMAIL, DISPLAY_NAME, { }, AUDIT_SOURCE, function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.equal(UsersError.BAD_FIELD);
|
||||
expect(error.reason).to.equal(BoxError.BAD_FIELD);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -145,7 +145,7 @@ describe('User', function () {
|
||||
users.create('', PASSWORD, EMAIL, DISPLAY_NAME, { }, AUDIT_SOURCE, function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.equal(UsersError.BAD_FIELD);
|
||||
expect(error.reason).to.equal(BoxError.BAD_FIELD);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -155,7 +155,7 @@ describe('User', function () {
|
||||
users.create(new Array(257).fill('Z').join(''), PASSWORD, EMAIL, DISPLAY_NAME, { }, AUDIT_SOURCE, function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.equal(UsersError.BAD_FIELD);
|
||||
expect(error.reason).to.equal(BoxError.BAD_FIELD);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -165,7 +165,7 @@ describe('User', function () {
|
||||
users.create('maybe.app', PASSWORD, EMAIL, DISPLAY_NAME, { }, AUDIT_SOURCE, function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.equal(UsersError.BAD_FIELD);
|
||||
expect(error.reason).to.equal(BoxError.BAD_FIELD);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -187,7 +187,7 @@ describe('User', function () {
|
||||
users.create(USERNAME, PASSWORD, EMAIL, DISPLAY_NAME, { }, AUDIT_SOURCE, function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).not.to.be.ok();
|
||||
expect(error.reason).to.equal(UsersError.ALREADY_EXISTS);
|
||||
expect(error.reason).to.equal(BoxError.ALREADY_EXISTS);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -197,7 +197,7 @@ describe('User', function () {
|
||||
users.create(USERNAME, '', EMAIL, DISPLAY_NAME, { }, AUDIT_SOURCE, function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).not.to.be.ok();
|
||||
expect(error.reason).to.equal(UsersError.BAD_FIELD);
|
||||
expect(error.reason).to.equal(BoxError.BAD_FIELD);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -210,7 +210,7 @@ describe('User', function () {
|
||||
|
||||
it('fails because there is no owner', function (done) {
|
||||
users.getOwner(function (error) {
|
||||
expect(error.reason).to.be(UsersError.NOT_FOUND);
|
||||
expect(error.reason).to.be(BoxError.NOT_FOUND);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -236,7 +236,7 @@ describe('User', function () {
|
||||
users.verify('somerandomid', PASSWORD, function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.equal(UsersError.NOT_FOUND);
|
||||
expect(error.reason).to.equal(BoxError.NOT_FOUND);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -246,7 +246,7 @@ describe('User', function () {
|
||||
users.verify(userObject.id, '', function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.equal(UsersError.INVALID_CREDENTIALS);
|
||||
expect(error.reason).to.equal(BoxError.INVALID_CREDENTIALS);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -256,7 +256,7 @@ describe('User', function () {
|
||||
users.verify(userObject.id, PASSWORD+PASSWORD, function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.equal(UsersError.INVALID_CREDENTIALS);
|
||||
expect(error.reason).to.equal(BoxError.INVALID_CREDENTIALS);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -273,8 +273,8 @@ describe('User', function () {
|
||||
|
||||
it('fails for ghost if not enabled', function (done) {
|
||||
users.verify(userObject.id, 'foobar', function (error) {
|
||||
expect(error).to.be.a(UsersError);
|
||||
expect(error.reason).to.equal(UsersError.INVALID_CREDENTIALS);
|
||||
expect(error).to.be.a(BoxError);
|
||||
expect(error.reason).to.equal(BoxError.INVALID_CREDENTIALS);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -287,8 +287,8 @@ describe('User', function () {
|
||||
users.verify(userObject.id, 'foobar', function (error) {
|
||||
fs.unlinkSync(constants.GHOST_USER_FILE);
|
||||
|
||||
expect(error).to.be.a(UsersError);
|
||||
expect(error.reason).to.equal(UsersError.INVALID_CREDENTIALS);
|
||||
expect(error).to.be.a(BoxError);
|
||||
expect(error.reason).to.equal(BoxError.INVALID_CREDENTIALS);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -336,7 +336,7 @@ describe('User', function () {
|
||||
users.verifyWithUsername(USERNAME+USERNAME, PASSWORD, function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.equal(UsersError.NOT_FOUND);
|
||||
expect(error.reason).to.equal(BoxError.NOT_FOUND);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -346,7 +346,7 @@ describe('User', function () {
|
||||
users.verifyWithUsername(USERNAME, '', function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.equal(UsersError.INVALID_CREDENTIALS);
|
||||
expect(error.reason).to.equal(BoxError.INVALID_CREDENTIALS);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -356,7 +356,7 @@ describe('User', function () {
|
||||
users.verifyWithUsername(USERNAME, PASSWORD+PASSWORD, function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.equal(UsersError.INVALID_CREDENTIALS);
|
||||
expect(error.reason).to.equal(BoxError.INVALID_CREDENTIALS);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -389,8 +389,8 @@ describe('User', function () {
|
||||
users.verifyWithUsername(USERNAME, 'foobar', function (error) {
|
||||
fs.unlinkSync(constants.GHOST_USER_FILE);
|
||||
|
||||
expect(error).to.be.a(UsersError);
|
||||
expect(error.reason).to.equal(UsersError.INVALID_CREDENTIALS);
|
||||
expect(error).to.be.a(BoxError);
|
||||
expect(error.reason).to.equal(BoxError.INVALID_CREDENTIALS);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -423,7 +423,7 @@ describe('User', function () {
|
||||
users.verifyWithEmail(EMAIL+EMAIL, PASSWORD, function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.equal(UsersError.NOT_FOUND);
|
||||
expect(error.reason).to.equal(BoxError.NOT_FOUND);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -433,7 +433,7 @@ describe('User', function () {
|
||||
users.verifyWithEmail(EMAIL, '', function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.equal(UsersError.INVALID_CREDENTIALS);
|
||||
expect(error.reason).to.equal(BoxError.INVALID_CREDENTIALS);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -443,7 +443,7 @@ describe('User', function () {
|
||||
users.verifyWithEmail(EMAIL, PASSWORD+PASSWORD, function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.equal(UsersError.INVALID_CREDENTIALS);
|
||||
expect(error.reason).to.equal(BoxError.INVALID_CREDENTIALS);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -476,8 +476,8 @@ describe('User', function () {
|
||||
users.verifyWithEmail(EMAIL, 'foobar', function (error) {
|
||||
fs.unlinkSync(constants.GHOST_USER_FILE);
|
||||
|
||||
expect(error).to.be.a(UsersError);
|
||||
expect(error.reason).to.equal(UsersError.INVALID_CREDENTIALS);
|
||||
expect(error).to.be.a(BoxError);
|
||||
expect(error.reason).to.equal(BoxError.INVALID_CREDENTIALS);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -512,7 +512,7 @@ describe('User', function () {
|
||||
|
||||
users.verify(userObject.id, PASSWORD, function (error) {
|
||||
expect(error).to.be.ok();
|
||||
expect(error.reason).to.equal(UsersError.NOT_FOUND);
|
||||
expect(error.reason).to.equal(BoxError.NOT_FOUND);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -586,8 +586,8 @@ describe('User', function () {
|
||||
it('fails due to unknown userid', function (done) {
|
||||
var data = { username: USERNAME_NEW, email: EMAIL_NEW, displayName: DISPLAY_NAME_NEW };
|
||||
users.update(USERNAME, data, AUDIT_SOURCE, function (error) {
|
||||
expect(error).to.be.a(UsersError);
|
||||
expect(error.reason).to.equal(UsersError.NOT_FOUND);
|
||||
expect(error).to.be.a(BoxError);
|
||||
expect(error.reason).to.equal(BoxError.NOT_FOUND);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -596,8 +596,8 @@ describe('User', function () {
|
||||
it('fails due to invalid email', function (done) {
|
||||
var data = { username: USERNAME_NEW, email: 'brokenemailaddress', displayName: DISPLAY_NAME_NEW };
|
||||
users.update(userObject.id, data, AUDIT_SOURCE, function (error) {
|
||||
expect(error).to.be.a(UsersError);
|
||||
expect(error.reason).to.equal(UsersError.BAD_FIELD);
|
||||
expect(error).to.be.a(BoxError);
|
||||
expect(error.reason).to.equal(BoxError.BAD_FIELD);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -804,7 +804,7 @@ describe('User', function () {
|
||||
users.verify(userObject.id, PASSWORD, function (error, result) {
|
||||
expect(error).to.be.ok();
|
||||
expect(result).to.not.be.ok();
|
||||
expect(error.reason).to.equal(UsersError.INVALID_CREDENTIALS);
|
||||
expect(error.reason).to.equal(BoxError.INVALID_CREDENTIALS);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -824,16 +824,16 @@ describe('User', function () {
|
||||
|
||||
it('fails due to unkown email', function (done) {
|
||||
users.resetPasswordByIdentifier('unknown@mail.com', function (error) {
|
||||
expect(error).to.be.an(UsersError);
|
||||
expect(error.reason).to.eql(UsersError.NOT_FOUND);
|
||||
expect(error).to.be.an(BoxError);
|
||||
expect(error.reason).to.eql(BoxError.NOT_FOUND);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('fails due to unkown username', function (done) {
|
||||
users.resetPasswordByIdentifier('unknown', function (error) {
|
||||
expect(error).to.be.an(UsersError);
|
||||
expect(error.reason).to.eql(UsersError.NOT_FOUND);
|
||||
expect(error).to.be.an(BoxError);
|
||||
expect(error.reason).to.eql(BoxError.NOT_FOUND);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -859,8 +859,8 @@ describe('User', function () {
|
||||
|
||||
it('fails for unknown user', function (done) {
|
||||
users.sendInvite('unknown user', { }, function (error) {
|
||||
expect(error).to.be.a(UsersError);
|
||||
expect(error.reason).to.equal(UsersError.NOT_FOUND);
|
||||
expect(error).to.be.a(BoxError);
|
||||
expect(error.reason).to.equal(BoxError.NOT_FOUND);
|
||||
|
||||
checkMails(0, done);
|
||||
});
|
||||
@@ -895,7 +895,7 @@ describe('User', function () {
|
||||
|
||||
it('fails for unknown user', function (done) {
|
||||
users.remove('unknown', AUDIT_SOURCE, function (error) {
|
||||
expect(error.reason).to.be(UsersError.NOT_FOUND);
|
||||
expect(error.reason).to.be(BoxError.NOT_FOUND);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user