From 8292dabed56b858fa2ccec7497627f5e5aa65181 Mon Sep 17 00:00:00 2001 From: Csaba Solya Date: Fri, 23 Feb 2018 11:03:53 +0100 Subject: add negative decrypt test --- test/unit/edge-encryptor-test.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test') diff --git a/test/unit/edge-encryptor-test.js b/test/unit/edge-encryptor-test.js index ef733a494..1dad4b91e 100644 --- a/test/unit/edge-encryptor-test.js +++ b/test/unit/edge-encryptor-test.js @@ -76,5 +76,25 @@ describe('EdgeEncryptor', function () { done(err) }) }) + + it('cannot decrypt the encrypted data with wrong password.', function (done) { + + edgeEncryptor.encrypt(password, data) + .then(function (encryptedData) { + edgeEncryptor.decrypt('wrong password', encryptedData) + .then(function (decryptedData) { + assert.fail('could decrypt with wrong password') + done() + }) + .catch(function (err) { + assert.ok(err instanceof Error) + assert.equal(err.message, 'Incorrect password') + done() + }) + }) + .catch(function (err) { + done(err) + }) + }) }) }) -- cgit