From 24a00058652233775cbe51446cba337b70cefdf1 Mon Sep 17 00:00:00 2001 From: Maximilian Krambach Date: Wed, 22 Aug 2018 19:07:05 +0200 Subject: js: add decrypt result options -- * As a decrypt result cannot be known beforehand, the decrypt operation may add an 'expect' property, taking either 'uint8' or 'base64', which will return the decrypted data in the appropiate formats. the return property 'format' will give a feedback on which option was taken. A test was added to reflect these changes. --- .../tests/encryptDecryptTest.js | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lang/js/BrowserTestExtension/tests/encryptDecryptTest.js') diff --git a/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js b/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js index 1efdf5cf..c10c5d06 100644 --- a/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js +++ b/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js @@ -144,6 +144,30 @@ describe('Encryption and Decryption', function (){ }); }).timeout(3000); + it('Random data, original data is and should stay base64 encoded', + function (done) { + let data = bigBoringString(0.001); + let b64data = btoa(data); + context.encrypt( + { data: b64data, publicKeys: good_fpr }) + .then(function (answer) { + expect(answer).to.not.be.empty; + expect(answer.data).to.be.a('string'); + expect(answer.data).to.include( + 'BEGIN PGP MESSAGE'); + expect(answer.data).to.include( + 'END PGP MESSAGE'); + context.decrypt({ + data:answer.data, expect: 'base64' }) + .then(function (result) { + expect(result).to.not.be.empty; + expect(result.data).to.be.a('string'); + expect(result.data).to.equal(b64data); + done(); + }); + }); + }).timeout(3000); + for (let j = 0; j < inputvalues.encrypt.good.data_nonascii_32.length; j++){ it('Roundtrip with >1MB non-ascii input meeting default chunksize (' + (j + 1) + '/' -- cgit v1.2.3