From cc831cde4a81a17ceaed1e0a1da594afdfea6b4e Mon Sep 17 00:00:00 2001 From: Sanjana Rajan Date: Tue, 4 Jul 2017 21:08:48 -0700 Subject: [PATCH] more 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 ff0bd761..3252d7c7 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 string cleartext and valid signatures - armored', function(done) { + it('Sign text with openpgp.sign and verify with openpgp.verify leads to same string cleartext and valid signatures', 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 - 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 }).then(function(signed) { + + var csMsg = openpgp.cleartext.readArmored(signed.data, true); + 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('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];