Move UsersError to BoxError
This commit is contained in:
@@ -13,7 +13,6 @@ var appdb = require('../appdb.js'),
|
||||
BoxError = require('../boxerror.js'),
|
||||
clientdb = require('../clientdb.js'),
|
||||
database = require('../database'),
|
||||
DatabaseError = require('../databaseerror.js'),
|
||||
domaindb = require('../domaindb'),
|
||||
eventlogdb = require('../eventlogdb.js'),
|
||||
expect = require('expect.js'),
|
||||
@@ -466,7 +465,7 @@ describe('database', function () {
|
||||
|
||||
userdb.add(tmp.id, tmp, function (error) {
|
||||
expect(error).to.be.ok();
|
||||
expect(error.reason).to.be(DatabaseError.ALREADY_EXISTS);
|
||||
expect(error.reason).to.be(BoxError.ALREADY_EXISTS);
|
||||
expect(error.message).to.equal('email already exists');
|
||||
done();
|
||||
});
|
||||
@@ -479,7 +478,7 @@ describe('database', function () {
|
||||
|
||||
userdb.add(tmp.id, tmp, function (error) {
|
||||
expect(error).to.be.ok();
|
||||
expect(error.reason).to.be(DatabaseError.ALREADY_EXISTS);
|
||||
expect(error.reason).to.be(BoxError.ALREADY_EXISTS);
|
||||
expect(error.message).to.equal('username already exists');
|
||||
done();
|
||||
});
|
||||
@@ -512,7 +511,7 @@ describe('database', function () {
|
||||
it('getByResetToken fails for empty resetToken', function (done) {
|
||||
userdb.getByResetToken(USER_0.email, '', function (error, user) {
|
||||
expect(error).to.be.ok();
|
||||
expect(error.reason).to.be(DatabaseError.INTERNAL_ERROR);
|
||||
expect(error.reason).to.be(BoxError.NOT_FOUND);
|
||||
expect(user).to.not.be.ok();
|
||||
done();
|
||||
});
|
||||
@@ -521,7 +520,7 @@ describe('database', function () {
|
||||
it('getByResetToken fails for bad email', function (done) {
|
||||
userdb.getByResetToken(USER_0.email + 'x', USER_0.resetToken, function (error, user) {
|
||||
expect(error).to.be.ok();
|
||||
expect(error.reason).to.be(DatabaseError.NOT_FOUND);
|
||||
expect(error.reason).to.be(BoxError.NOT_FOUND);
|
||||
expect(user).to.not.be.ok();
|
||||
done();
|
||||
});
|
||||
@@ -633,7 +632,7 @@ describe('database', function () {
|
||||
it('can update the user with already existing email', function (done) {
|
||||
userdb.update(USER_0.id, { email: USER_2.email }, function (error) {
|
||||
expect(error).to.be.ok();
|
||||
expect(error.reason).to.be(DatabaseError.ALREADY_EXISTS);
|
||||
expect(error.reason).to.be(BoxError.ALREADY_EXISTS);
|
||||
expect(error.message).to.equal('email already exists');
|
||||
done();
|
||||
});
|
||||
@@ -642,7 +641,7 @@ describe('database', function () {
|
||||
it('can update the user with already existing username', function (done) {
|
||||
userdb.update(USER_0.id, { username: USER_2.username }, function (error) {
|
||||
expect(error).to.be.ok();
|
||||
expect(error.reason).to.be(DatabaseError.ALREADY_EXISTS);
|
||||
expect(error.reason).to.be(BoxError.ALREADY_EXISTS);
|
||||
expect(error.message).to.equal('username already exists');
|
||||
done();
|
||||
});
|
||||
@@ -657,7 +656,7 @@ describe('database', function () {
|
||||
it('cannot del non-existing user', function (done) {
|
||||
userdb.del(USER_0.id + USER_0.id, function (error) {
|
||||
expect(error).to.be.ok();
|
||||
expect(error.reason).to.be(DatabaseError.NOT_FOUND);
|
||||
expect(error.reason).to.be(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.WRONG_PASSWORD);
|
||||
expect(error.reason).to.equal(UsersError.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.WRONG_PASSWORD);
|
||||
expect(error.reason).to.equal(UsersError.INVALID_CREDENTIALS);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -274,7 +274,7 @@ 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.WRONG_PASSWORD);
|
||||
expect(error.reason).to.equal(UsersError.INVALID_CREDENTIALS);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -288,7 +288,7 @@ describe('User', function () {
|
||||
fs.unlinkSync(constants.GHOST_USER_FILE);
|
||||
|
||||
expect(error).to.be.a(UsersError);
|
||||
expect(error.reason).to.equal(UsersError.WRONG_PASSWORD);
|
||||
expect(error.reason).to.equal(UsersError.INVALID_CREDENTIALS);
|
||||
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.WRONG_PASSWORD);
|
||||
expect(error.reason).to.equal(UsersError.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.WRONG_PASSWORD);
|
||||
expect(error.reason).to.equal(UsersError.INVALID_CREDENTIALS);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -390,7 +390,7 @@ describe('User', function () {
|
||||
fs.unlinkSync(constants.GHOST_USER_FILE);
|
||||
|
||||
expect(error).to.be.a(UsersError);
|
||||
expect(error.reason).to.equal(UsersError.WRONG_PASSWORD);
|
||||
expect(error.reason).to.equal(UsersError.INVALID_CREDENTIALS);
|
||||
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.WRONG_PASSWORD);
|
||||
expect(error.reason).to.equal(UsersError.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.WRONG_PASSWORD);
|
||||
expect(error.reason).to.equal(UsersError.INVALID_CREDENTIALS);
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -477,7 +477,7 @@ describe('User', function () {
|
||||
fs.unlinkSync(constants.GHOST_USER_FILE);
|
||||
|
||||
expect(error).to.be.a(UsersError);
|
||||
expect(error.reason).to.equal(UsersError.WRONG_PASSWORD);
|
||||
expect(error.reason).to.equal(UsersError.INVALID_CREDENTIALS);
|
||||
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.WRONG_PASSWORD);
|
||||
expect(error.reason).to.equal(UsersError.INVALID_CREDENTIALS);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user