From e2a9c06d5f654ff463662f23ce23e354c1fb7453 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Wed, 29 Oct 2014 08:43:00 -0300 Subject: [PATCH] unify crypto tests --- test/cryptoUtil.js | 38 -------------------------------------- test/util.crypto.js | 37 ++++++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 47 deletions(-) delete mode 100644 test/cryptoUtil.js diff --git a/test/cryptoUtil.js b/test/cryptoUtil.js deleted file mode 100644 index 7ae9632b0..000000000 --- a/test/cryptoUtil.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -var _ = require('lodash'); -var chai = chai || require('chai'); -var sinon = sinon || require('sinon'); -var should = chai.should(); -var crypto = require('../js/util/crypto.js'); - -describe('cryptoUtil', function() { - - var tests = [ - { - salt: 'mjuBtGybi/4=', - iterations: 10, - word: '123456', - phrase: 'UUNLzkU5b2aT2/bIoyYwL3teyiFuRYEJtGCGQ0y0aEDciEtNCX0Wb73j4gmoCWl++epj6StBQg4SorTROZ2wFA==', - },{ - salt: 'mjuBtGybi/4=', - iterations: 5, - word: '123456', - phrase: '+3uClcHrIU52WGHPHBwbIDFirhbiIORYTDPs9xFLiXAkR2dEVN9gNoGtqhBPdi9U47tPkPoRqZtqXDaeetXflQ==', - },{ - salt: 'asklhehuhug24', - iterations: 5, - word: '123456', - phrase: 'lI82NmwibnUCHSQVQunv3aL0XCimZyFj/TZlHNIXV5Rzbf6TEj5L/335N/t7k2zUVub6XmMaWvufqmvSqA4znA==', - } - ]; - - var test=0; - _.each(tests,function(t){ - it('should generate a passphrase. Test case:' + test++,function(){ - var phrase = crypto.kdf(t.word, t.salt, t.iterations); - phrase.should.equal(t.phrase); - }); - }); -}); - diff --git a/test/util.crypto.js b/test/util.crypto.js index 598d5e75b..0590ad54a 100644 --- a/test/util.crypto.js +++ b/test/util.crypto.js @@ -5,15 +5,6 @@ var assert = require('assert'); describe('crypto utils', function() { - it('should use pbkdf2 to generate a passphrase from password', function() { - var salt = 'mjuBtGybi/4='; - var iterations = 10; - var pass = '123456'; - var passphrase = cryptoUtils.kdf(pass, salt, iterations); - - passphrase.toString().should.equal('IoP+EbmhibgvHAkgCAaSDL3Y73UvU96pEPkKtSb0Qazb1RKFVWR6fjkKGp/qBCImljzND3hRAws9bigszrqhfg=='); - }); - it('should decrypt what it encrypts', function() { var key = 'My secret key'; @@ -33,4 +24,32 @@ describe('crypto utils', function() { assert(decrypted === null); }); + var tests = [ + { + salt: 'mjuBtGybi/4=', + iterations: 10, + word: '123456', + phrase: 'UUNLzkU5b2aT2/bIoyYwL3teyiFuRYEJtGCGQ0y0aEDciEtNCX0Wb73j4gmoCWl++epj6StBQg4SorTROZ2wFA==', + },{ + salt: 'mjuBtGybi/4=', + iterations: 5, + word: '123456', + phrase: '+3uClcHrIU52WGHPHBwbIDFirhbiIORYTDPs9xFLiXAkR2dEVN9gNoGtqhBPdi9U47tPkPoRqZtqXDaeetXflQ==', + },{ + salt: 'asklhehuhug24', + iterations: 5, + word: '123456', + phrase: 'lI82NmwibnUCHSQVQunv3aL0XCimZyFj/TZlHNIXV5Rzbf6TEj5L/335N/t7k2zUVub6XmMaWvufqmvSqA4znA==', + } + ]; + + var test=0; + _.each(tests,function(t){ + it('should generate a passphrase. Test case:' + test++,function(){ + var phrase = cryptoUtils.kdf(t.word, t.salt, t.iterations); + phrase.should.equal(t.phrase); + }); + }); + + });