From cdb62b44c768616f31d81228e51082eb650480af Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 26 Mar 2017 11:34:19 +0200 Subject: [PATCH] basic tests for CryptTool classes encryption and compression functions --- js/test.js | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/js/test.js b/js/test.js index 462d6ff1..5625710f 100644 --- a/js/test.js +++ b/js/test.js @@ -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 () {