js: changed verify signature result infos

--

* the resulting information of verify now are as documented,
  and the same as in a decrypt callback
This commit is contained in:
Maximilian Krambach 2018-08-22 12:44:05 +02:00
parent 93f674d33d
commit d8fd4aad8a
2 changed files with 28 additions and 21 deletions

View File

@ -38,12 +38,12 @@ describe('Verifying data', function () {
const message = inputvalues.signedMessage.good; const message = inputvalues.signedMessage.good;
context.verify(message).then(function (result){ context.verify(message).then(function (result){
expect(result.data).to.be.a('string'); expect(result.data).to.be.a('string');
expect(result.all_valid).to.be.true; expect(result.signatures.all_valid).to.be.true;
expect(result.count).to.equal(1); expect(result.signatures.count).to.equal(1);
expect(result.signatures.good).to.be.an('array'); expect(result.signatures.signatures.good).to.be.an('array');
expect(result.signatures.good.length).to.equal(1); expect(result.signatures.signatures.good.length).to.equal(1);
expect(result.signatures.good[0].fingerprint).to.be.a('string'); expect(result.signatures.signatures.good[0].fingerprint).to.be.a('string');
expect(result.signatures.good[0].valid).to.be.true; expect(result.signatures.signatures.good[0].valid).to.be.true;
done(); done();
}); });
}); });
@ -52,12 +52,14 @@ describe('Verifying data', function () {
const message = inputvalues.signedMessage.bad; const message = inputvalues.signedMessage.bad;
context.verify(message).then(function (result){ context.verify(message).then(function (result){
expect(result.data).to.be.a('string'); expect(result.data).to.be.a('string');
expect(result.all_valid).to.be.false; expect(result.signatures.all_valid).to.be.false;
expect(result.count).to.equal(1); expect(result.signatures.count).to.equal(1);
expect(result.signatures.bad).to.be.an('array'); expect(result.signatures.signatures.bad).to.be.an('array');
expect(result.signatures.bad.length).to.equal(1); expect(result.signatures.signatures.bad.length).to.equal(1);
expect(result.signatures.bad[0].fingerprint).to.be.a('string'); expect(result.signatures.signatures.bad[0].fingerprint)
expect(result.signatures.bad[0].valid).to.be.false; .to.be.a('string');
expect(result.signatures.signatures.bad[0].valid)
.to.be.false;
done(); done();
}); });
}); });
@ -70,13 +72,16 @@ describe('Verifying data', function () {
context.verify(message_encsign.data).then(function (result){ context.verify(message_encsign.data).then(function (result){
expect(result.data).to.equal(message_enc.data); expect(result.data).to.equal(message_enc.data);
expect(result.data).to.be.a('string'); expect(result.data).to.be.a('string');
expect(result.all_valid).to.be.true; expect(result.signatures.all_valid).to.be.true;
expect(result.count).to.equal(1); expect(result.signatures.count).to.equal(1);
expect(result.signatures.good).to.be.an('array'); expect(result.signatures.signatures.good)
expect(result.signatures.good.length).to.equal(1); .to.be.an('array');
expect( expect(result.signatures.signatures.good.length)
result.signatures.good[0].fingerprint).to.equal(fpr); .to.equal(1);
expect(result.signatures.good[0].valid).to.be.true; expect(result.signatures.signatures.good[0].fingerprint)
.to.equal(fpr);
expect(result.signatures.signatures.good[0].valid)
.to.be.true;
done(); done();
}); });
}); });

View File

@ -301,8 +301,10 @@ export class GpgME {
if (!message.info || !message.info.signatures){ if (!message.info || !message.info.signatures){
reject(gpgme_error('SIG_NO_SIGS')); reject(gpgme_error('SIG_NO_SIGS'));
} else { } else {
let _result = collectSignatures(message.info.signatures); let _result = {
if (_result instanceof Error){ signatures: collectSignatures(message.info.signatures)
};
if (_result.signatures instanceof Error){
reject(_result.signatures); reject(_result.signatures);
} else { } else {
_result.is_mime = message.info.is_mime? true: false; _result.is_mime = message.info.is_mime? true: false;