Fix browser tests
This commit is contained in:
parent
454ca1d879
commit
6b4d44dbb1
|
@ -345,7 +345,7 @@ export function verify({ message, publicKeys, signature=null, date=new Date() })
|
||||||
publicKeys = toArray(publicKeys);
|
publicKeys = toArray(publicKeys);
|
||||||
|
|
||||||
if (asyncProxy) { // use web worker if available
|
if (asyncProxy) { // use web worker if available
|
||||||
return asyncProxy.delegate('verify', { message, publicKeys, signature });
|
return asyncProxy.delegate('verify', { message, publicKeys, signature, date });
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve().then(async function() {
|
return Promise.resolve().then(async function() {
|
||||||
|
|
|
@ -60,7 +60,7 @@ export function clonePackets(options) {
|
||||||
if (options.message instanceof Message) {
|
if (options.message instanceof Message) {
|
||||||
options.message = options.message.packets;
|
options.message = options.message.packets;
|
||||||
} else if (options.message instanceof CleartextMessage) {
|
} else if (options.message instanceof CleartextMessage) {
|
||||||
options.message.signature = options.message.signature.packets;
|
options.message = { text: options.message.text, signature: options.message.signature.packets };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (options.signature && (options.signature instanceof Signature)) {
|
if (options.signature && (options.signature instanceof Signature)) {
|
||||||
|
|
|
@ -868,7 +868,12 @@ describe('OpenPGP.js public api tests', function() {
|
||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(function (done) {
|
||||||
expect(privateKey.keys[0].decrypt(passphrase)).to.be.true;
|
expect(privateKey.keys[0].decrypt(passphrase)).to.be.true;
|
||||||
privateKey.keys[0].verifyPrimaryUser().then(() => done());
|
Promise.all([
|
||||||
|
privateKey.keys[0].verifyPrimaryUser(),
|
||||||
|
privateKey_2000_2008.keys[0].verifyPrimaryUser(),
|
||||||
|
privateKey_1337.keys[0].verifyPrimaryUser(),
|
||||||
|
privateKey_2038_2045.keys[0].verifyPrimaryUser()
|
||||||
|
]).then(() => done());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should encrypt then decrypt', function () {
|
it('should encrypt then decrypt', function () {
|
||||||
|
@ -1556,27 +1561,27 @@ describe('OpenPGP.js public api tests', function() {
|
||||||
const future = new Date(2040, 5, 5, 5, 5, 5, 0);
|
const future = new Date(2040, 5, 5, 5, 5, 5, 0);
|
||||||
const data = new Uint8Array([3, 14, 15, 92, 65, 35, 59]);
|
const data = new Uint8Array([3, 14, 15, 92, 65, 35, 59]);
|
||||||
const signOpt = {
|
const signOpt = {
|
||||||
data,
|
data,
|
||||||
privateKeys: privateKey_2038_2045.keys,
|
privateKeys: privateKey_2038_2045.keys,
|
||||||
detached: true,
|
detached: true,
|
||||||
date: future,
|
date: future,
|
||||||
armor: false
|
armor: false
|
||||||
};
|
};
|
||||||
const verifyOpt = {
|
const verifyOpt = {
|
||||||
publicKeys: publicKey_2038_2045.keys,
|
publicKeys: publicKey_2038_2045.keys,
|
||||||
date: future
|
date: future
|
||||||
};
|
};
|
||||||
return openpgp.sign(signOpt).then(function (signed) {
|
return openpgp.sign(signOpt).then(function (signed) {
|
||||||
verifyOpt.message = openpgp.message.fromBinary(data);
|
verifyOpt.message = openpgp.message.fromBinary(data);
|
||||||
verifyOpt.signature = signed.signature;
|
verifyOpt.signature = signed.signature;
|
||||||
return openpgp.verify(verifyOpt);
|
return openpgp.verify(verifyOpt);
|
||||||
}).then(function (verified) {
|
}).then(function (verified) {
|
||||||
expect(+verified.signatures[0].signature.packets[0].created).to.equal(+future);
|
expect(+verified.signatures[0].signature.packets[0].created).to.equal(+future);
|
||||||
expect(verified.data).to.equal(data);
|
expect(Array.from(verified.data)).to.deep.equal(Array.from(data));
|
||||||
expect(verified.signatures[0].valid).to.be.true;
|
expect(verified.signatures[0].valid).to.be.true;
|
||||||
expect(signOpt.privateKeys[0].getSigningKeyPacket(verified.signatures[0].keyid, future))
|
expect(signOpt.privateKeys[0].getSigningKeyPacket(verified.signatures[0].keyid, future))
|
||||||
.to.be.not.null;
|
.to.be.not.null;
|
||||||
expect(verified.signatures[0].signature.packets.length).to.equal(1);
|
expect(verified.signatures[0].signature.packets.length).to.equal(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user