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

View File

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