mirror of
https://github.com/moparisthebest/mail
synced 2025-01-30 22:50:17 -05:00
implemented send email in client email dao and it test
This commit is contained in:
parent
6177b40f1b
commit
eda008258d
@ -64,7 +64,7 @@ app.dao.CloudStorage = function(window, $) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Encrypted Mails
|
// Encrypted Mail storage
|
||||||
//
|
//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -233,4 +233,15 @@ app.dao.EmailDAO = function(_, crypto, devicestorage, cloudstorage, naclCrypto,
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a plaintext Email to the user's outbox in the cloud
|
||||||
|
*/
|
||||||
|
this.sendEmail = function(email, callback) {
|
||||||
|
var userId = this.account.get('emailAddress');
|
||||||
|
|
||||||
|
cloudstorage.putEncryptedItem(email, 'email', userId, 'outbox', function(err) {
|
||||||
|
callback(err);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
@ -1,21 +1,21 @@
|
|||||||
module("CloudStorage DAO");
|
module("CloudStorage DAO");
|
||||||
|
|
||||||
var cloudstoragedao_test = {
|
var cloudstoragedao_test = {
|
||||||
user: 'test@atlasdev.onmicrosoft.com',
|
user: 'email.dao.it.test@mail.whiteout.io',
|
||||||
password: 'Xoza76645',
|
password: 'hellosafe',
|
||||||
keySize: 128,
|
keySize: 128,
|
||||||
ivSize: 104
|
ivSize: 104
|
||||||
};
|
};
|
||||||
|
|
||||||
asyncTest("Init", 1, function() {
|
asyncTest("Init", 1, function() {
|
||||||
// init dependencies
|
// init dependencies
|
||||||
var util = new app.crypto.Util(window, uuid);
|
cloudstoragedao_test.util = new app.crypto.Util(window, uuid);
|
||||||
var jsonDao = new app.dao.LawnchairDAO(window);
|
var jsonDao = new app.dao.LawnchairDAO(window);
|
||||||
var crypto = new app.crypto.Crypto(window, util);
|
var crypto = new app.crypto.Crypto(window, cloudstoragedao_test.util);
|
||||||
var naclCrypto = new app.crypto.NaclCrypto(nacl, util);
|
var naclCrypto = new app.crypto.NaclCrypto(nacl, cloudstoragedao_test.util);
|
||||||
cloudstoragedao_test.storage = new app.dao.DeviceStorage(util, crypto, jsonDao, null);
|
cloudstoragedao_test.storage = new app.dao.DeviceStorage(cloudstoragedao_test.util, crypto, jsonDao, null);
|
||||||
cloudstoragedao_test.cloudstorage = new app.dao.CloudStorage(window, $);
|
cloudstoragedao_test.cloudstorage = new app.dao.CloudStorage(window, $);
|
||||||
cloudstoragedao_test.emailDao = new app.dao.EmailDAO(_, crypto, cloudstoragedao_test.storage, cloudstoragedao_test.cloudstorage, naclCrypto, util);
|
cloudstoragedao_test.emailDao = new app.dao.EmailDAO(_, crypto, cloudstoragedao_test.storage, cloudstoragedao_test.cloudstorage, naclCrypto, cloudstoragedao_test.util);
|
||||||
|
|
||||||
// clear db before tests
|
// clear db before tests
|
||||||
jsonDao.clear(function(err) {
|
jsonDao.clear(function(err) {
|
||||||
@ -91,6 +91,23 @@ asyncTest("Init", 1, function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
asyncTest("Send Plaintext Email item", 1, function() {
|
||||||
|
|
||||||
|
var email = new app.model.Email({
|
||||||
|
id: cloudstoragedao_test.util.UUID(),
|
||||||
|
from: cloudstoragedao_test.user, // sender address
|
||||||
|
to: [cloudstoragedao_test.user], // list of receivers
|
||||||
|
subject: 'Client Email DAO Test', // Subject line
|
||||||
|
body: 'Hello world' // plaintext body
|
||||||
|
});
|
||||||
|
|
||||||
|
cloudstoragedao_test.emailDao.sendEmail(email, function(err) {
|
||||||
|
ok(!err, 'Email sent');
|
||||||
|
|
||||||
|
start();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
asyncTest("Check virtual inbox, re-encrypt and push to cloud", 1, function() {
|
asyncTest("Check virtual inbox, re-encrypt and push to cloud", 1, function() {
|
||||||
cloudstoragedao_test.emailDao.checkVInbox(function(err) {
|
cloudstoragedao_test.emailDao.checkVInbox(function(err) {
|
||||||
ok(!err, 'Synced items');
|
ok(!err, 'Synced items');
|
||||||
|
Loading…
Reference in New Issue
Block a user