add alias tests
This commit is contained in:
parent
69fc2408b4
commit
1898fe20fb
28
cloudron.js
28
cloudron.js
|
@ -343,6 +343,17 @@ Cloudron.prototype.addUser = function (username, email) {
|
||||||
return res.body;
|
return res.body;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Cloudron.prototype.setAliases = function (owner, aliases) {
|
||||||
|
var res = request.put(this._origin + '/api/v1/mailboxes/' + owner.username + '/aliases')
|
||||||
|
.query({ access_token: this._credentials.accessToken })
|
||||||
|
.send({ aliases: aliases })
|
||||||
|
.end();
|
||||||
|
|
||||||
|
common.verifyResponse2xx(res, 'Could not set aliases');
|
||||||
|
|
||||||
|
return res.body;
|
||||||
|
};
|
||||||
|
|
||||||
Cloudron.prototype.resetPassword = function (resetToken, password) {
|
Cloudron.prototype.resetPassword = function (resetToken, password) {
|
||||||
var res = request.get(this._origin + '/api/v1/session/password/reset.html').query({ reset_token: resetToken }).end();
|
var res = request.get(this._origin + '/api/v1/session/password/reset.html').query({ reset_token: resetToken }).end();
|
||||||
common.verifyResponse2xx(res, 'Could not get password setup site');
|
common.verifyResponse2xx(res, 'Could not get password setup site');
|
||||||
|
@ -614,18 +625,18 @@ Cloudron.prototype.checkForUpdates = function () {
|
||||||
.end();
|
.end();
|
||||||
};
|
};
|
||||||
|
|
||||||
Cloudron.prototype.sendMail = function (owner, to, callback) {
|
Cloudron.prototype.sendMail = function (account, to, callback) {
|
||||||
var transport = nodemailer.createTransport(smtpTransport({
|
var transport = nodemailer.createTransport(smtpTransport({
|
||||||
host: this._adminFqdn,
|
host: this._adminFqdn,
|
||||||
port: 587,
|
port: 587,
|
||||||
auth: {
|
auth: {
|
||||||
user: owner.username,
|
user: account.username,
|
||||||
pass: owner.password
|
pass: account.password
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
var mailOptions = {
|
var mailOptions = {
|
||||||
from: owner.username + '@'+ this._box.domain,
|
from: (account.from || account.username) + '@'+ this._box.domain,
|
||||||
to: to,
|
to: to,
|
||||||
subject: 'Hi from e2e test - ' + this._box.domain,
|
subject: 'Hi from e2e test - ' + this._box.domain,
|
||||||
text: 'This release depends on you'
|
text: 'This release depends on you'
|
||||||
|
@ -634,10 +645,10 @@ Cloudron.prototype.sendMail = function (owner, to, callback) {
|
||||||
transport.sendMail(mailOptions, callback);
|
transport.sendMail(mailOptions, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
Cloudron.prototype.checkMail = function (owner, callback) {
|
Cloudron.prototype.checkMail = function (account, callback) {
|
||||||
var imap = new ImapProbe({
|
var imap = new ImapProbe({
|
||||||
user: owner.username,
|
user: account.username,
|
||||||
password: owner.password,
|
password: account.password,
|
||||||
host: this._adminFqdn,
|
host: this._adminFqdn,
|
||||||
port: 993, // imap port
|
port: 993, // imap port
|
||||||
tls: true,
|
tls: true,
|
||||||
|
@ -647,8 +658,7 @@ Cloudron.prototype.checkMail = function (owner, callback) {
|
||||||
|
|
||||||
imap.probe({
|
imap.probe({
|
||||||
subject: new RegExp('^Hi from e2e test - ' + this._box.domain + '$'),
|
subject: new RegExp('^Hi from e2e test - ' + this._box.domain + '$'),
|
||||||
to: new RegExp(owner.username + '@' + this._box.domain),
|
to: new RegExp((account.to || account.username) + '@' + this._box.domain),
|
||||||
body: /This release depends on you/
|
body: /This release depends on you/
|
||||||
}, callback);
|
}, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,8 @@ var AppStore = require('../appstore.js'),
|
||||||
dnsSync = require('dns-sync'),
|
dnsSync = require('dns-sync'),
|
||||||
ImapProbe = require('../imap-probe.js'),
|
ImapProbe = require('../imap-probe.js'),
|
||||||
mailer = require('../mailer.js'),
|
mailer = require('../mailer.js'),
|
||||||
sleep = require('sleep').sleep;
|
sleep = require('sleep').sleep,
|
||||||
|
_ = require('underscore');
|
||||||
|
|
||||||
require('colors');
|
require('colors');
|
||||||
|
|
||||||
|
@ -65,41 +66,64 @@ describe('Cloudron backup testing', function () {
|
||||||
cloudron.setCredentials(owner.password, token);
|
cloudron.setCredentials(owner.password, token);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('send mail to cloudron user', function (done) {
|
describe('mail tests as normal user', function () {
|
||||||
mailer.sendMailToCloudronUser(owner.username + '@' + box.domain, done);
|
it('can send mail to cloudron user', function (done) {
|
||||||
|
mailer.sendMailToCloudronUser(owner.username + '@' + cloudron.fqdn(), done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('did receive mail', function (done) {
|
||||||
|
cloudron.checkMail(owner, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can send mail from cloudron user', function (done) {
|
||||||
|
cloudron.sendMail(owner, 'test+fromcloudron@cloudron.io', done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('did send mail from cloudron user', function (done) {
|
||||||
|
imap.probe({
|
||||||
|
subject: new RegExp('^Hi from e2e test$'),
|
||||||
|
to: /test+fromcloudron@cloudron.io/,
|
||||||
|
body: /This release depends on you/
|
||||||
|
}, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can save a sieve script', function (done) {
|
||||||
|
cloudron.saveSieveScript(owner, done);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can save a sieve script', function (done) {
|
describe('mail alias tests', function () {
|
||||||
cloudron.saveSieveScript(owner, done);
|
it('can set aliases', function () {
|
||||||
|
cloudron.setAliases(owner, ['admin', 'mail']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can send email to alias', function (done) {
|
||||||
|
mailer.sendMailToCloudronUser('admin@' + box.domain, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('did receive mail as alias (using owner name creds)', function (done) {
|
||||||
|
cloudron.checkMail(_.extend(owner, { to: 'admin' }), done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('did receive mail to alias (using alias creds)', function (done) {
|
||||||
|
cloudron.checkMail({ username: 'admin', password: owner.password, to: 'admin' }, done);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can receive mail', function (done) {
|
describe('app pre-restore', function () {
|
||||||
cloudron.checkMail(owner, done);
|
var location = 'test' + (Math.random() * 10000).toFixed();
|
||||||
});
|
it('can install app', function () {
|
||||||
|
var manifest = appStore.getManifest(common.TESTAPP_ID, common.TESTAPP_VERSION);
|
||||||
|
appId = cloudron.installApp(location, manifest);
|
||||||
|
});
|
||||||
|
|
||||||
it('can send mail', function (done) {
|
it('can populate the addons', function () {
|
||||||
cloudron.sendMail(owner, 'test+fromcloudron@cloudron.io', done);
|
cloudron.populateAddons(cloudron.appFqdn(location));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sent mail successfully', function (done) {
|
it('can check the addons', function () {
|
||||||
imap.probe({
|
cloudron.checkAddons(cloudron.appFqdn(location), owner);
|
||||||
subject: new RegExp('^Hi from e2e test$'),
|
});
|
||||||
body: /This release depends on you/
|
|
||||||
}, done);
|
|
||||||
});
|
|
||||||
|
|
||||||
var location = 'test' + (Math.random() * 10000).toFixed();
|
|
||||||
it('can install app', function () {
|
|
||||||
var manifest = appStore.getManifest(common.TESTAPP_ID, common.TESTAPP_VERSION);
|
|
||||||
appId = cloudron.installApp(location, manifest);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can populate the addons', function () {
|
|
||||||
cloudron.populateAddons(cloudron.appFqdn(location));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can check the addons', function () {
|
|
||||||
cloudron.checkAddons(cloudron.appFqdn(location), owner);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can backup the box', function () {
|
it('can backup the box', function () {
|
||||||
|
@ -127,24 +151,28 @@ describe('Cloudron backup testing', function () {
|
||||||
cloudron.setCredentials(owner.password, token);
|
cloudron.setCredentials(owner.password, token);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('retains old mail', function (done) {
|
describe('mail tests as normal user', function() {
|
||||||
cloudron.checkMail(owner, done);
|
it('retains old mail', function (done) {
|
||||||
|
cloudron.checkMail(owner, owner.username, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can check sieve script', function (done) {
|
||||||
|
cloudron.checkSieveScript(owner, done);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can check sieve script', function (done) {
|
describe('app tests', function () {
|
||||||
cloudron.checkSieveScript(owner, done);
|
it('wait for app', function () {
|
||||||
});
|
cloudron.waitForApp(appId);
|
||||||
|
});
|
||||||
|
|
||||||
it('wait for app', function () {
|
it('can check the addons', function () {
|
||||||
cloudron.waitForApp(appId);
|
cloudron.checkAddons(cloudron.appFqdn(location), owner);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can check the addons', function () {
|
it('can uninstall app', function () {
|
||||||
cloudron.checkAddons(cloudron.appFqdn(location), owner);
|
cloudron.uninstallApp(appId);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can uninstall app', function () {
|
|
||||||
cloudron.uninstallApp(appId);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can delete the cloudron', function () {
|
it('can delete the cloudron', function () {
|
||||||
|
|
Loading…
Reference in New Issue