add tests for inactive mailbox and list
This commit is contained in:
@@ -108,12 +108,12 @@ function setup(done) {
|
||||
callback();
|
||||
});
|
||||
},
|
||||
(done) => mailboxdb.addMailbox(USER_0.username.toLowerCase(), DOMAIN_0.domain, USER_0.id, mail.OWNERTYPE_USER, done),
|
||||
(done) => mailboxdb.addMailbox(USER_0.username.toLowerCase(), DOMAIN_0.domain, { ownerId: USER_0.id, ownerType: mail.OWNERTYPE_USER, active: true }, done),
|
||||
(done) => mailboxdb.setAliasesForName(USER_0.username.toLowerCase(), DOMAIN_0.domain, [ { name: USER_0_ALIAS.toLocaleLowerCase(), domain: DOMAIN_0.domain} ], done),
|
||||
appdb.update.bind(null, APP_0.id, { containerId: APP_0.containerId }),
|
||||
appdb.setAddonConfig.bind(null, APP_0.id, 'sendmail', [{ name: 'MAIL_SMTP_USERNAME', value : `${APP_0.location}.app@${DOMAIN_0.domain}` }, { name: 'MAIL_SMTP_PASSWORD', value : 'sendmailpassword' }]),
|
||||
appdb.setAddonConfig.bind(null, APP_0.id, 'recvmail', [{ name: 'MAIL_IMAP_USERNAME', value : `${APP_0.location}.app@${DOMAIN_0.domain}` }, { name: 'MAIL_IMAP_PASSWORD', value : 'recvmailpassword' }]),
|
||||
mailboxdb.addMailbox.bind(null, APP_0.location + '.app', APP_0.domain, APP_0.id, mail.OWNERTYPE_USER),
|
||||
mailboxdb.addMailbox.bind(null, APP_0.location + '.app', APP_0.domain, { ownerId: APP_0.id, ownerType: mail.OWNERTYPE_USER, active: true }),
|
||||
|
||||
function (callback) {
|
||||
users.create(USER_1.username, USER_1.password, USER_1.email, USER_0.displayName, { }, AUDIT_SOURCE, function (error, result) {
|
||||
@@ -742,6 +742,17 @@ describe('Ldap', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('cannot get inactive mailbox', function (done) {
|
||||
mailboxdb.updateMailbox(USER_0.username.toLowerCase(), DOMAIN_0.domain, { ownerId: USER_0.id, ownerType: mail.OWNERTYPE_USER, active: false }, function (error) {
|
||||
if (error) return done(error);
|
||||
ldapSearch('cn=' + USER_0.username + '@example.com,ou=mailboxes,dc=cloudron', 'objectclass=mailbox', function (error) {
|
||||
expect(error).to.be.a(ldap.NoSuchObjectError);
|
||||
|
||||
mailboxdb.updateMailbox(USER_0.username.toLowerCase(), DOMAIN_0.domain, { ownerId: USER_0.id, ownerType: mail.OWNERTYPE_USER, active: true }, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('search aliases', function () {
|
||||
@@ -791,7 +802,7 @@ describe('Ldap', function () {
|
||||
|
||||
describe('search mailing list', function () {
|
||||
before(function (done) {
|
||||
mailboxdb.addList('devs', DOMAIN_0.domain, [ USER_0.username.toLowerCase() + '@' + DOMAIN_0.domain , USER_1.username.toLowerCase() + '@external.com' ], false /* membersOnly */, done);
|
||||
mailboxdb.addList('devs', DOMAIN_0.domain, { members: [ USER_0.username.toLowerCase() + '@' + DOMAIN_0.domain , USER_1.username.toLowerCase() + '@external.com' ], membersOnly: false, active: true }, done);
|
||||
});
|
||||
|
||||
it('get specific list', function (done) {
|
||||
@@ -810,6 +821,17 @@ describe('Ldap', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('inactive list', function (done) {
|
||||
mailboxdb.updateList('devs', DOMAIN_0.domain, { members: [ USER_0.username.toLowerCase() + '@' + DOMAIN_0.domain , USER_1.username.toLowerCase() + '@external.com' ], membersOnly: false, active: false }, function (error) {
|
||||
if (error) return done(error);
|
||||
|
||||
ldapSearch('cn=devs@example.com,ou=mailinglists,dc=cloudron', 'objectclass=mailGroup', function (error, entries) {
|
||||
expect(error).to.be.a(ldap.NoSuchObjectError);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('user mailbox bind', function () {
|
||||
@@ -929,6 +951,27 @@ describe('Ldap', function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('does not allow for inactive mailbox', function (done) {
|
||||
// use maildb to not trigger further events
|
||||
maildb.update(DOMAIN_0.domain, { enabled: true }, function (error) {
|
||||
if (error) return done(error);
|
||||
|
||||
mailboxdb.updateMailbox(USER_0.username.toLowerCase(), DOMAIN_0.domain, { ownerId: USER_0.id, ownerType: mail.OWNERTYPE_USER, active: false }, function (error) {
|
||||
if(error) return done(error);
|
||||
|
||||
var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT });
|
||||
|
||||
client.bind('cn=' + USER_0.username.toLocaleLowerCase() + '@' + DOMAIN_0.domain + ',ou=sendmail,dc=cloudron', USER_0.password, function (error) {
|
||||
expect(error).to.be.a(ldap.NoSuchObjectError);
|
||||
|
||||
client.unbind();
|
||||
|
||||
maildb.update(DOMAIN_0.domain, { enabled: false }, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('app sendmail bind', function () {
|
||||
@@ -969,7 +1012,10 @@ describe('Ldap', function () {
|
||||
|
||||
describe('user recvmail bind', function () {
|
||||
before(function (done) {
|
||||
maildb.update(DOMAIN_0.domain, { enabled: false }, done);
|
||||
async.series([
|
||||
maildb.update.bind(null, DOMAIN_0.domain, { enabled: false }),
|
||||
mailboxdb.updateMailbox.bind(null, USER_0.username.toLowerCase(), DOMAIN_0.domain, { ownerId: USER_0.id, ownerType: mail.OWNERTYPE_USER, active: true })
|
||||
], done);
|
||||
});
|
||||
|
||||
it('email disabled - cannot find domain email', function (done) {
|
||||
@@ -1025,6 +1071,28 @@ describe('Ldap', function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('does not allow for inactive mailbox', function (done) {
|
||||
// use maildb to not trigger further events
|
||||
maildb.update(DOMAIN_0.domain, { enabled: true }, function (error) {
|
||||
expect(error).not.to.be.ok();
|
||||
|
||||
mailboxdb.updateMailbox(USER_0.username.toLowerCase(), DOMAIN_0.domain, { ownerId: USER_0.id, ownerType: mail.OWNERTYPE_USER, active: false }, function (error) {
|
||||
if (error) return done(error);
|
||||
|
||||
var client = ldap.createClient({ url: 'ldap://127.0.0.1:' + constants.LDAP_PORT });
|
||||
|
||||
client.bind('cn=' + USER_0.username + '@example.com,ou=recvmail,dc=cloudron', USER_0.password, function (error) {
|
||||
expect(error).to.be.a(ldap.NoSuchObjectError);
|
||||
|
||||
client.unbind();
|
||||
|
||||
maildb.update(DOMAIN_0.domain, { enabled: false }, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('app recvmail bind', function () {
|
||||
|
||||
Reference in New Issue
Block a user