1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-29 12:22:22 -05:00

different lawnchair for each user

This commit is contained in:
Tankred Hase 2013-06-03 04:26:17 +02:00
parent cb8df440f2
commit 04a3ab2a34
6 changed files with 31 additions and 12 deletions

View File

@ -4,13 +4,21 @@
app.dao.LawnchairDAO = function(Lawnchair) {
'use strict';
var db = new Lawnchair({
name: 'dataStore'
}, function(lc) {
if (!lc) {
throw new Error('Lawnchair init failed!');
var db;
this.init = function(dbName) {
if (!dbName) {
throw new Error('Lawnchair DB name must be specified!');
}
});
db = new Lawnchair({
name: dbName
}, function(lc) {
if (!lc) {
throw new Error('Lawnchair init failed!');
}
});
};
/**
* Create or update an object

View File

@ -34,6 +34,7 @@ asyncTest("Init", 1, function() {
// init dependencies
cloudstoragedao_test.util = new cryptoLib.Util(window, uuid);
var jsonDao = new app.dao.LawnchairDAO(Lawnchair);
jsonDao.init(cloudstoragedao_test.user);
cloudstoragedao_test.crypto = new app.crypto.Crypto(window, cloudstoragedao_test.util);
cloudstoragedao_test.storage = new app.dao.DeviceStorage(cloudstoragedao_test.util, cloudstoragedao_test.crypto, jsonDao, null);
cloudstoragedao_test.cloudstorage = new app.dao.CloudStorage(window, $);
@ -121,8 +122,9 @@ asyncTest("Get User Keypair", 2, function() {
asyncTest("Get Public Keys", 2, function() {
var pubkeyIds = [{
_id: cloudstoragedao_test.keypair.publicKey._id
}];
_id: cloudstoragedao_test.keypair.publicKey._id
}
];
cloudstoragedao_test.keychain.getPublicKeys(pubkeyIds, function(err, pubkeys) {
ok(!err);
deepEqual(pubkeys[0], cloudstoragedao_test.keypair.publicKey, "Fetch public key");

View File

@ -12,6 +12,7 @@ asyncTest("Init", 3, function() {
// init dependencies
devicestorage_test.util = new cryptoLib.Util(window, uuid);
devicestorage_test.jsonDao = new app.dao.LawnchairDAO(Lawnchair);
devicestorage_test.jsonDao.init(devicestorage_test.user);
devicestorage_test.crypto = new app.crypto.Crypto(window, devicestorage_test.util);
devicestorage_test.storage = new app.dao.DeviceStorage(devicestorage_test.util, devicestorage_test.crypto, devicestorage_test.jsonDao, null);
ok(devicestorage_test.storage, 'DeviceStorageDAO');
@ -47,7 +48,9 @@ asyncTest("Encrypt list for user", 2, function() {
equal(encryptedList.length, devicestorage_test.list.length, 'Encrypt list');
encryptedList.forEach(function(i) {
i.sentDate = _.findWhere(devicestorage_test.list, {id: i.id}).sentDate;
i.sentDate = _.findWhere(devicestorage_test.list, {
id: i.id
}).sentDate;
});
devicestorage_test.encryptedList = encryptedList;

View File

@ -12,6 +12,7 @@ asyncTest("Init", 3, function() {
// init dependencies
var util = new cryptoLib.Util(window, uuid);
var jsonDao = new app.dao.LawnchairDAO(Lawnchair);
jsonDao.init(emaildao_test.user);
emaildao_test.crypto = new app.crypto.Crypto(window, util);
emaildao_test.storage = new app.dao.DeviceStorage(util, emaildao_test.crypto, jsonDao, null);
// cloud storage stub

View File

@ -12,6 +12,7 @@ asyncTest("Init", 2, function() {
// init dependencies
var util = new cryptoLib.Util(window, uuid);
var jsonDao = new app.dao.LawnchairDAO(Lawnchair);
jsonDao.init(keychaindao_test.user);
var crypto = new app.crypto.Crypto(window, util);
// cloud storage stub
var cloudstorageStub = {
@ -68,8 +69,9 @@ asyncTest("Get User Keypair", 2, function() {
asyncTest("Get Public Keys", 2, function() {
var pubkeyIds = [{
_id: keychaindao_test.keypair.publicKey._id
}];
_id: keychaindao_test.keypair.publicKey._id
}
];
keychaindao_test.keychainDao.getPublicKeys(pubkeyIds, function(err, pubkeys) {
ok(!err);
deepEqual(pubkeys[0], keychaindao_test.keypair.publicKey, "Fetch public key");

View File

@ -1,10 +1,13 @@
module("Lawnchair DAO");
var lawnchairdao_test = {};
var lawnchairdao_test = {
user: 'lawnchair@test.com'
};
asyncTest("Init", 2, function() {
// init dependencies
lawnchairdao_test.jsonDao = new app.dao.LawnchairDAO(Lawnchair);
lawnchairdao_test.jsonDao.init(lawnchairdao_test.user);
ok(lawnchairdao_test.jsonDao, 'LanwchairDAO');
// clear db before test