From 479d8265337712398987a833247131934492600d Mon Sep 17 00:00:00 2001 From: larabr <7375870+larabr@users.noreply.github.com> Date: Tue, 10 Nov 2020 17:33:54 +0100 Subject: [PATCH] Remove armor comment and version by default (#1170) --- src/config/config.js | 4 ++-- test/general/openpgp.js | 29 +++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/config/config.js b/src/config/config.js index 50ff3de7..9948f09e 100644 --- a/src/config/config.js +++ b/src/config/config.js @@ -152,12 +152,12 @@ export default { * @memberof module:config * @property {Boolean} showVersion Whether to include {@link module:config/config.versionString} in armored messages */ - showVersion: true, + showVersion: false, /** * @memberof module:config * @property {Boolean} showComment Whether to include {@link module:config/config.commentString} in armored messages */ - showComment: true, + showComment: false, /** * @memberof module:config * @property {String} versionString A version string to be included in armored messages diff --git a/test/general/openpgp.js b/test/general/openpgp.js index 4c73436b..24dc3a0f 100644 --- a/test/general/openpgp.js +++ b/test/general/openpgp.js @@ -745,14 +745,27 @@ module.exports = () => describe('OpenPGP.js public api tests', function() { }); it('Configuration', async function() { - openpgp.config.showVersion = false; - openpgp.config.commentString = 'different'; - - return openpgp.encrypt({ publicKeys:publicKey, message:openpgp.Message.fromText(plaintext) }).then(function(encrypted) { - expect(encrypted).to.exist; - expect(encrypted).not.to.match(/^Version:/); - expect(encrypted).to.match(/Comment: different/); - }); + const showCommentVal = openpgp.config.showComment; + const showVersionVal = openpgp.config.showVersion; + const commentStringVal = openpgp.config.commentString; + + try { + const encryptedDefault = await openpgp.encrypt({ publicKeys:publicKey, message:openpgp.Message.fromText(plaintext) }); + expect(encryptedDefault).to.exist; + expect(encryptedDefault).not.to.match(/^Version:/); + expect(encryptedDefault).not.to.match(/^Comment:/); + + openpgp.config.showComment = true; + openpgp.config.commentString = 'different'; + const encryptedWithComment = await openpgp.encrypt({ publicKeys:publicKey, message:openpgp.Message.fromText(plaintext) }); + expect(encryptedWithComment).to.exist; + expect(encryptedWithComment).not.to.match(/^Version:/); + expect(encryptedWithComment).to.match(/Comment: different/); + } finally { + openpgp.config.showComment = showCommentVal; + openpgp.config.showVersion = showVersionVal; + openpgp.config.commentString = commentStringVal; + } }); it('Decrypting key with wrong passphrase rejected', async function () {