Skip to content

Commit

Permalink
Remove armor comment and version by default (#1170)
Browse files Browse the repository at this point in the history
  • Loading branch information
larabr authored and twiss committed Feb 9, 2021
1 parent ad7d654 commit 479d826
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 21 additions & 8 deletions test/general/openpgp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit 479d826

Please sign in to comment.