From ba7d6b437f2e03a9e2bb46dcda846cee1f816ce1 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 3 Nov 2016 16:06:57 -0700 Subject: Fix password validation and persistence issue Was wiping the vault on each successful password attempt... :P --- test/integration/lib/encryptor-test.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test') diff --git a/test/integration/lib/encryptor-test.js b/test/integration/lib/encryptor-test.js index 1c8a7605a..d42608152 100644 --- a/test/integration/lib/encryptor-test.js +++ b/test/integration/lib/encryptor-test.js @@ -43,3 +43,25 @@ QUnit.test('encryptor:encrypt & decrypt', function(assert) { }) }) + +QUnit.test('encryptor:encrypt & decrypt with wrong password', function(assert) { + var done = assert.async(); + var password, data, encrypted, wrongPassword + + password = 'a sample passw0rd' + wrongPassword = 'a wrong password' + data = { foo: 'data to encrypt' } + + encryptor.encrypt(password, data) + .then(function(encryptedStr) { + assert.equal(typeof encryptedStr, 'string', 'returns a string') + return encryptor.decrypt(wrongPassword, encryptedStr) + }) + .then(function (decryptedObj) { + assert.equal(!decryptedObj, true, 'Wrong password should not decrypt') + done() + }) + .catch(function(reason) { + done() + }) +}) -- cgit v1.2.3