From 225f586970aafeca2225b34a85ce4bd244161e05 Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Fri, 27 Jul 2018 14:57:42 +0200 Subject: [PATCH] Make ECC tests less idiosyncratic --- test/general/brainpool.js | 3 +++ test/general/ecc_nist.js | 4 ++-- test/general/streaming.js | 2 +- test/general/testInputs.js | 4 ++-- test/general/x25519.js | 4 +++- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/test/general/brainpool.js b/test/general/brainpool.js index 65d0ccec..1a50ce3c 100644 --- a/test/general/brainpool.js +++ b/test/general/brainpool.js @@ -118,6 +118,8 @@ describe('Brainpool Cryptography', function () { 'second test message', '', '-----BEGIN PGP SIGNATURE-----', + 'Version: OpenPGP.js v3.1.0', + 'Comment: https://openpgpjs.org', '', 'wl4EARMKABAFAltbE34JEDfhaphrivmeAABaXQD+LzOhFxTqz8+IcaD3xzww', 'EjEn0u7qgCFem9PHPD4wqAcA/1WQE3N7DIwRG45HFd+ZBo4vcuRkWK+Q6CHl', @@ -125,6 +127,7 @@ describe('Brainpool Cryptography', function () { '=obwy', '-----END PGP SIGNATURE-----' ].join('\n') + } }; async function load_pub_key(name) { diff --git a/test/general/ecc_nist.js b/test/general/ecc_nist.js index 19680625..e6faff65 100644 --- a/test/general/ecc_nist.js +++ b/test/general/ecc_nist.js @@ -106,8 +106,8 @@ describe('Elliptic Curve Cryptography', function () { 'O Romeo, Romeo! Wherefore art thou Romeo?', '', '-----BEGIN PGP SIGNATURE-----', - 'Version: GnuPG v2', - 'Comment: GnuPG v2.1+libgcrypt-1.7', + 'Version: OpenPGP.js v3.1.0', + 'Comment: https://openpgpjs.org', '', 'wl4EARMIABAFAltbFFMJEGQRYCGVm9/gAAAjugD/W/OZ++qiNlhy08OOflAN', 'rjjX3rknSZyUkr96HD4VWVsBAPL9QjyHI3714cdkQmwYGiG8TVrtPetnqHho', diff --git a/test/general/streaming.js b/test/general/streaming.js index 0d6d7b35..f4b9e4ac 100644 --- a/test/general/streaming.js +++ b/test/general/streaming.js @@ -431,7 +431,7 @@ function tests() { }); expect(util.isStream(decrypted.data)).to.equal(expectedType); const reader = openpgp.stream.getReader(decrypted.data); - expect((await reader.peekBytes(200)).toString('utf8').substr(0, 50)).to.equal(plaintext[0]); + expect((await reader.peekBytes(256)).toString('utf8').substr(0, 64)).to.equal(plaintext[0]); if (i > 10) throw new Error('Data did not arrive early.'); expect((await reader.readToEnd()).toString('utf8')).to.equal(util.concat(plaintext)); } finally { diff --git a/test/general/testInputs.js b/test/general/testInputs.js index dc0dcacd..2659a50a 100644 --- a/test/general/testInputs.js +++ b/test/general/testInputs.js @@ -1,6 +1,6 @@ /** - * Generates a 50 character long javascript string out of the whole utf-8 range. + * Generates a 64 character long javascript string out of the whole utf-8 range. */ function createSomeMessage(){ const length = 50; @@ -9,7 +9,7 @@ function createSomeMessage(){ arr.push(String.fromCharCode( Math.floor(Math.random() * 10174) + 1)); } - return arr.join('').replace(/\r/g, '\n'); + return '  \t' + arr.join('').replace(/\r/g, '\n') + '  \t\n한국어/조선말'; } module.exports = { diff --git a/test/general/x25519.js b/test/general/x25519.js index 201085fa..e0cefeb1 100644 --- a/test/general/x25519.js +++ b/test/general/x25519.js @@ -54,6 +54,8 @@ describe('X25519 Cryptography', function () { 'Hi, Light wrote this!', '', '-----BEGIN PGP SIGNATURE-----', + 'Version: OpenPGP.js v3.1.0', + 'Comment: https://openpgpjs.org', '', 'wl4EARYKABAFAltbFNAJEB7N8CbAJFgwAAAhcAEA5b2MIQNxQYj8TAMyuhZJ', 'UvxEgPS8DU59Kxw5F9+oldQBAN4mA+SOJyTxEx4oyyLh+8RD27dqyeDpmXju', @@ -178,7 +180,7 @@ describe('X25519 Cryptography', function () { const result = await openpgp.verify({ publicKeys: [pub], message: msg}); expect(result).to.exist; - expect(result.data).to.equal(randomData); + expect(result.data).to.equal(openpgp.util.removeTrailingSpaces(randomData)); expect(result.signatures).to.have.length(1); expect(result.signatures[0].valid).to.be.true; });