basic tests for CryptTool classes encryption and compression functions

This commit is contained in:
El RIDO 2017-03-26 11:34:19 +02:00
parent 37f5d99bc4
commit cdb62b44c7
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92

View file

@ -2,6 +2,9 @@
var jsc = require('jsverify'),
jsdom = require('jsdom-global'),
cleanup = jsdom(),
base64lib = require('./base64-2.1.9'),
rawdeflatelib = require('./rawdeflate-0.5'),
rawinflatelib = require('./rawinflate-0.3'),
a2zString = ['a','b','c','d','e','f','g','h','i','j','k','l','m',
'n','o','p','q','r','s','t','u','v','w','x','y','z'],
@ -19,9 +22,9 @@ var jsc = require('jsverify'),
global.$ = global.jQuery = require('./jquery-3.1.1');
global.sjcl = require('./sjcl-1.0.6');
global.Base64 = require('./base64-2.1.9');
global.RawDeflate = require('./rawdeflate-0.5');
require('./rawinflate-0.3');
global.Base64 = base64lib.Base64;
global.RawDeflate = rawdeflatelib.RawDeflate;
global.RawDeflate.inflate = rawinflatelib.RawDeflate.inflate;
require('./privatebin');
// redirect console messages to log file
@ -436,6 +439,28 @@ describe('I18n', function () {
});
});
describe('CryptTool', function () {
describe('cipher & decipher', function () {
this.timeout(20000);
it('can en- and decrypt any message', function () {
jsc.check(jsc.forall(
'string',
'string',
'string',
function (key, password, message) {
return message === $.PrivateBin.CryptTool.decipher(
key,
password,
$.PrivateBin.CryptTool.cipher(key, password, message)
);
}
),
// reducing amount of checks as running 100 takes about 5 minutes
{tests: 5, quiet: true});
});
});
});
describe('Model', function () {
describe('getPasteId', function () {
before(function () {