test that user.del removed mailbox and aliases
This commit is contained in:
@@ -887,6 +887,18 @@ describe('User', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can set aliases', function (done) {
|
||||||
|
user.setAliases(userObject.id, [ 'everything', 'is', 'awesome' ], function (error) {
|
||||||
|
expect(error).to.be(null);
|
||||||
|
|
||||||
|
mailboxdb.getAliasesByName(USERNAME.toLowerCase(), function (error, results) {
|
||||||
|
expect(error).to.be(null);
|
||||||
|
expect(results.length).to.be(3);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('can remove valid user', function (done) {
|
it('can remove valid user', function (done) {
|
||||||
user.remove(userObject.id, { }, function (error) {
|
user.remove(userObject.id, { }, function (error) {
|
||||||
expect(error).to.be(null);
|
expect(error).to.be(null);
|
||||||
@@ -894,12 +906,16 @@ describe('User', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('did delete mailbox', function (done) {
|
it('did delete mailbox and aliases', function (done) {
|
||||||
mailboxdb.getMailbox(userObject.username.toLowerCase(), function (error, mailbox) {
|
mailboxdb.getMailbox(userObject.username.toLowerCase(), function (error, mailbox) {
|
||||||
expect(error.reason).to.be(DatabaseError.NOT_FOUND);
|
expect(error.reason).to.be(DatabaseError.NOT_FOUND);
|
||||||
done();
|
|
||||||
|
mailboxdb.getAliasesByName(USERNAME.toLowerCase(), function (error, results) {
|
||||||
|
expect(error).to.be(null);
|
||||||
|
expect(results.length).to.be(0);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ function removeUser(userId, auditSource, callback) {
|
|||||||
|
|
||||||
eventlog.add(eventlog.ACTION_USER_REMOVE, auditSource, { userId: userId });
|
eventlog.add(eventlog.ACTION_USER_REMOVE, auditSource, { userId: userId });
|
||||||
|
|
||||||
if (user.username) mailboxdb.delByOwnerId(user.id, callback); else callback();
|
asyncIf(!!user.username, mailboxdb.delByOwnerId.bind(null, user.id), callback);
|
||||||
|
|
||||||
mailer.userRemoved(user);
|
mailer.userRemoved(user);
|
||||||
});
|
});
|
||||||
@@ -588,6 +588,8 @@ function setAliases(userId, aliases, callback) {
|
|||||||
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new UserError(UserError.NOT_FOUND));
|
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new UserError(UserError.NOT_FOUND));
|
||||||
if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error));
|
if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error));
|
||||||
|
|
||||||
|
if (!user.username) return new UserError(UserError.BAD_FIELD, 'Username must be set before settings aliases');
|
||||||
|
|
||||||
mailboxdb.setAliasesByName(user.username, aliases, function (error) {
|
mailboxdb.setAliasesByName(user.username, aliases, function (error) {
|
||||||
if (error && error.reason === DatabaseError.ALREADY_EXISTS) return callback(new UserError(UserError.ALREADY_EXISTS, error.message));
|
if (error && error.reason === DatabaseError.ALREADY_EXISTS) return callback(new UserError(UserError.ALREADY_EXISTS, error.message));
|
||||||
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new UserError(UserError.NOT_FOUND));
|
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new UserError(UserError.NOT_FOUND));
|
||||||
|
|||||||
Reference in New Issue
Block a user