1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-29 20:32:15 -05:00
mail/test/test-data.js

56 lines
2.3 KiB
JavaScript
Raw Normal View History

define(['cryptoLib/util', 'js/app-config'], function(util) {
2013-06-10 11:57:33 -04:00
'use strict';
2013-04-11 03:07:03 -04:00
2013-06-10 11:57:33 -04:00
var self = {};
2013-04-11 03:07:03 -04:00
2013-06-10 11:57:33 -04:00
self.getEmailCollection = function(size) {
2013-03-13 11:58:46 -04:00
// create test data
var i, mail, collection = [],
bigAssString = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet,';
2013-03-13 11:58:46 -04:00
for (i = 0; i < size; i++) {
mail = {
2013-05-15 08:14:08 -04:00
id: i + '',
2013-04-11 03:07:03 -04:00
from: 'john@from.com',
to: ['jack@to.com'],
2013-03-13 11:58:46 -04:00
subject: 'Important stuff ' + i,
sentDate: (1971 + i) + '-03-13 18:17:53',
body: bigAssString
};
2013-04-11 03:07:03 -04:00
collection.push(mail);
2013-03-13 11:58:46 -04:00
}
2013-04-11 03:07:03 -04:00
2013-03-13 11:58:46 -04:00
return collection;
};
2013-04-11 03:07:03 -04:00
2013-06-10 11:57:33 -04:00
self.packageCollectionForEncryption = function(collection, keySize, ivSize) {
2013-03-13 11:58:46 -04:00
// package json objects for batch encrytion
var envelope, envelopes = [];
2013-04-11 03:07:03 -04:00
2013-03-13 11:58:46 -04:00
collection.forEach(function(model) {
envelope = {
2013-04-11 03:07:03 -04:00
id: model.id,
2013-03-13 11:58:46 -04:00
plaintext: model.toJSON(),
key: util.random(keySize),
iv: util.random(ivSize)
};
2013-04-11 03:07:03 -04:00
envelopes.push(envelope);
2013-03-13 11:58:46 -04:00
});
2013-04-11 03:07:03 -04:00
2013-03-13 11:58:46 -04:00
return envelopes;
};
2013-04-11 03:07:03 -04:00
2013-06-10 11:57:33 -04:00
self.generateBigString = function(iterations) {
2013-06-10 16:02:29 -04:00
var testMessage = '';
2013-03-13 11:58:46 -04:00
// generate test data
2013-04-11 03:07:03 -04:00
for (var i = 0; i < iterations; i++) {
2013-06-10 16:02:29 -04:00
testMessage += 'aslghaksfdhsakjzfgasjfdgsauk';
2013-03-13 11:58:46 -04:00
}
2013-04-11 03:07:03 -04:00
2013-06-10 16:02:29 -04:00
return testMessage;
2013-03-13 11:58:46 -04:00
};
2013-04-11 03:07:03 -04:00
2013-06-10 11:57:33 -04:00
return self;
});