test multiple private key signing cleartext

This commit is contained in:
Sanjana Rajan 2018-02-14 17:30:35 +01:00
parent 94b12e566b
commit 2ffd81553d

View File

@ -1270,6 +1270,29 @@ describe('OpenPGP.js public api tests', function() {
});
});
it('should sign and verify cleartext data with multiple private keys', function () {
const privKeyDE = openpgp.key.readArmored(priv_key_de).keys[0];
privKeyDE.decrypt(passphrase);
const signOpt = {
data: plaintext,
privateKeys: [privateKey.keys[0], privKeyDE]
};
const verifyOpt = {
publicKeys: publicKey.keys
};
return openpgp.sign(signOpt).then(function (signed) {
expect(signed.data).to.match(/-----BEGIN PGP SIGNED MESSAGE-----/);
verifyOpt.message = openpgp.cleartext.readArmored(signed.data);
return openpgp.verify(verifyOpt);
}).then(function (verified) {
expect(verified.data).to.equal(plaintext);
expect(verified.signatures[0].valid).to.be.true;
expect(verified.signatures[0].keyid.toHex()).to.equal(privateKey.keys[0].getSigningKeyPacket().getKeyId().toHex());
expect(verified.signatures[0].signature.packets.length).to.equal(1);
});
});
it('should sign and verify cleartext data with detached signatures', function () {
const signOpt = {
data: plaintext,