From 697eab19cd8ba01a710912740024b1c4b2fcce2d Mon Sep 17 00:00:00 2001 From: Sanjana Rajan Date: Tue, 4 Jul 2017 17:03:56 -0700 Subject: [PATCH] add tests --- test/general/signature.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/test/general/signature.js b/test/general/signature.js index dacc59da..ff0bd761 100644 --- a/test/general/signature.js +++ b/test/general/signature.js @@ -527,7 +527,7 @@ describe("Signature", function() { }); }); - it('Sign text with openpgp.sign and verify with openpgp.verify leads to same cleartext and valid signatures', function(done) { + it('Sign text with openpgp.sign and verify with openpgp.verify leads to same string cleartext and valid signatures - armored', function(done) { var plaintext = 'short message\nnext line\n한국어/조선말'; var pubKey = openpgp.key.readArmored(pub_key_arm2).keys[0]; var privKey = openpgp.key.readArmored(priv_key_arm2).keys[0]; @@ -549,6 +549,28 @@ describe("Signature", function() { }); + it('Sign text with openpgp.sign and verify with openpgp.verify leads to same bytes cleartext and valid signatures - not armored', function(done) { + var plaintext = openpgp.util.str2Uint8Array('short message\nnext line\n한국어/조선말'); + var pubKey = openpgp.key.readArmored(pub_key_arm2).keys[0]; + var privKey = openpgp.key.readArmored(priv_key_arm2).keys[0]; + privKey.getSigningKeyPacket().decrypt('hello world'); + + openpgp.sign({ privateKeys:[privKey], data:plaintext, armor:false }).then(function(signed) { + + var csMsg = signed.message; + return openpgp.verify({ publicKeys:[pubKey], message:csMsg }); + + }).then(function(cleartextSig) { + expect(cleartextSig).to.exist; + expect(cleartextSig.data).to.deep.equal(plaintext); + expect(cleartextSig.signatures).to.have.length(1); + expect(cleartextSig.signatures[0].valid).to.be.true; + expect(cleartextSig.signatures[0].signature.packets.length).to.equal(1); + done(); + }); + + }); + it('Verify primary key revocation signature', function(done) { var pubKey = openpgp.key.readArmored(pub_revoked).keys[0];