1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-10 19:25:03 -05:00
mail/test/unit/keychain-dao-test.js
2013-05-27 19:25:45 +02:00

71 lines
1.4 KiB
JavaScript

module("Keychain DAO");
var keychaindao_test = {
user: 'keychaindao_test@example.com',
password: 'Password',
keySize: 128,
ivSize: 128,
rsaKeySize: 512
};
asyncTest("Init", 2, function() {
// init dependencies
var util = new cryptoLib.Util(window, uuid);
var jsonDao = new app.dao.LawnchairDAO(window);
var crypto = new app.crypto.Crypto(window, util);
// cloud storage stub
var cloudstorageStub = {
syncPrivateKey: function(emailAdress, storedKey, callback) {
callback();
},
putPublicKey: function(pk, callback) {
callback();
}
};
keychaindao_test.keychainDao = new app.dao.KeychainDAO(jsonDao, cloudstorageStub);
ok(keychaindao_test.keychainDao);
// clear db before test
jsonDao.clear(function() {
ok(true, 'cleared db');
start();
});
});
asyncTest("Put User Keypair", 1, function() {
keychaindao_test.keypair = {
publicKey: {
_id: '1',
userId: keychaindao_test.user,
publicKey: 'asdf'
},
privateKey: {
_id: '1',
userId: keychaindao_test.user,
encryptedKey: 'qwer',
iv: 'yxvc'
}
};
keychaindao_test.keychainDao.putUserKeyPair(keychaindao_test.keypair, function(err) {
ok(!err);
start();
});
});
asyncTest("Get User Keypair", 2, function() {
keychaindao_test.keychainDao.getUserKeyPair(keychaindao_test.user, function(err, keypair) {
ok(!err);
ok(keypair && keypair.publicKey && keypair.privateKey);
start();
});
});
// asyncTest("Get Public Keys", 1, function() {
// });