test user can send email

This commit is contained in:
Girish Ramakrishnan 2016-06-24 00:03:26 -05:00
parent a5f48e3575
commit 780dffecaa
3 changed files with 43 additions and 3 deletions

View File

@ -8,8 +8,10 @@ var assert = require('assert'),
dns = require('dns'),
ImapProbe = require('./imap-probe.js'),
querystring = require('querystring'),
nodemailer = require('nodemailer'),
once = require('once'),
request = require('superagent-sync'),
smtpTransport = require('nodemailer-smtp-transport'),
sleep = require('sleep').sleep,
tls = require('tls'),
url = require('url'),
@ -625,3 +627,23 @@ Cloudron.prototype.checkForUpdates = function () {
.query({ access_token: this._credentials.accessToken })
.end();
};
Cloudron.prototype.sendMail = function (owner, to, callback) {
var transport = nodemailer.createTransport(smtpTransport({
host: this._adminFqdn,
port: 587,
auth: {
user: owner.username,
pass: owner.password
}
}));
var mailOptions = {
from: owner.username + '@'+ this._box.domain,
to: to,
subject: 'Hello from e2e test',
text: 'The release depends on you'
};
transport.sendMail(mailOptions, callback);
};

View File

@ -1,5 +1,3 @@
/* jslint node: true */
'use strict';
var assert = require('assert'),

View File

@ -10,6 +10,7 @@ var AppStore = require('../appstore.js'),
Cloudron = require('../cloudron.js'),
common = require('../common.js'),
dnsSync = require('dns-sync'),
ImapProbe = require('../imap-probe.js'),
mailer = require('../mailer.js'),
sleep = require('sleep').sleep;
@ -27,6 +28,15 @@ describe('Cloudron backup testing', function () {
var admin = common.getAdmin();
var cloudron, appId, box, backupInfo;
var imap = new ImapProbe({
user: process.env.IMAP_USERNAME,
password: process.env.IMAP_PASSWORD,
host: process.env.IMAP_HOST,
port: 993, // imap port
tls: true,
readOnly: true
});
it('can login to the store', function () {
var accessToken = appStore.getAccessToken(owner);
appStore.setCredentials(owner.password, accessToken);
@ -67,6 +77,17 @@ describe('Cloudron backup testing', function () {
cloudron.checkMail(owner, done);
});
it('can send mail', function (done) {
cloudron.sendMail(owner, 'test+fromcloudron@cloudron.io', done);
});
it('sent mail successfully', function (done) {
imap.probe({
subject: new RegExp('^Hello from e2e test$'),
body: /The 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);
@ -130,4 +151,3 @@ describe('Cloudron backup testing', function () {
appStore.deleteCloudron(box);
});
});