Test CFB, GCM, worker, asm.js, native cases
This commit is contained in:
parent
f4fc274f14
commit
da3fbf8965
|
@ -1,4 +1,4 @@
|
||||||
/* globals tryWorker: true */
|
/* globals tryTests: true */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ describe('OpenPGP.js public api tests', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('encrypt, decrypt, sign, verify - integration tests', function() {
|
describe('encrypt, decrypt, sign, verify - integration tests', function() {
|
||||||
var privateKey, publicKey, zeroCopyVal, useNativeVal;
|
var privateKey, publicKey, zeroCopyVal, useNativeVal, aead_protectVal;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
publicKey = openpgp.key.readArmored(pub_key);
|
publicKey = openpgp.key.readArmored(pub_key);
|
||||||
|
@ -414,11 +414,13 @@ describe('OpenPGP.js public api tests', function() {
|
||||||
expect(privateKey.err).to.not.exist;
|
expect(privateKey.err).to.not.exist;
|
||||||
zeroCopyVal = openpgp.config.zeroCopy;
|
zeroCopyVal = openpgp.config.zeroCopy;
|
||||||
useNativeVal = openpgp.config.useNative;
|
useNativeVal = openpgp.config.useNative;
|
||||||
|
aead_protectVal = openpgp.config.aead_protect;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
openpgp.config.zeroCopy = zeroCopyVal;
|
openpgp.config.zeroCopy = zeroCopyVal;
|
||||||
openpgp.config.useNative = useNativeVal;
|
openpgp.config.useNative = useNativeVal;
|
||||||
|
openpgp.config.aead_protect = aead_protectVal;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Decrypting key with wrong passphrase returns false', function () {
|
it('Decrypting key with wrong passphrase returns false', function () {
|
||||||
|
@ -429,13 +431,42 @@ describe('OpenPGP.js public api tests', function() {
|
||||||
expect(privateKey.keys[0].decrypt(passphrase)).to.be.true;
|
expect(privateKey.keys[0].decrypt(passphrase)).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('without Worker', tests);
|
tryTests('CFB mode (asm.js)', tests, {
|
||||||
|
if: true,
|
||||||
|
beforeEach: function() {
|
||||||
|
openpgp.config.useNative = false;
|
||||||
|
openpgp.config.aead_protect = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
tryWorker('with Worker', tests, function() {
|
tryTests('CFB mode (asm.js, worker)', tests, {
|
||||||
openpgp.config.useNative = false;
|
if: typeof window !== 'undefined' && window.Worker,
|
||||||
openpgp.initWorker({ path:'../dist/openpgp.worker.js' });
|
before: function() {
|
||||||
}, function() {
|
openpgp.initWorker({ path:'../dist/openpgp.worker.js' });
|
||||||
openpgp.destroyWorker(); // cleanup worker in case of failure
|
},
|
||||||
|
beforeEach: function() {
|
||||||
|
openpgp.config.useNative = false;
|
||||||
|
openpgp.config.aead_protect = false;
|
||||||
|
},
|
||||||
|
after: function() {
|
||||||
|
openpgp.destroyWorker();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tryTests('GCM mode (asm.js)', tests, {
|
||||||
|
if: true,
|
||||||
|
beforeEach: function() {
|
||||||
|
openpgp.config.useNative = false;
|
||||||
|
openpgp.config.aead_protect = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tryTests('GCM mode (native)', tests, {
|
||||||
|
if: openpgp.util.getWebCrypto(),
|
||||||
|
beforeEach: function() {
|
||||||
|
openpgp.config.useNative = true;
|
||||||
|
openpgp.config.aead_protect = true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function tests() {
|
function tests() {
|
||||||
|
|
|
@ -6,17 +6,19 @@
|
||||||
return new Promise(function(res, rej) { rej(val); });
|
return new Promise(function(res, rej) { rej(val); });
|
||||||
};
|
};
|
||||||
|
|
||||||
(typeof window !== 'undefined' ? window : global).tryWorker = function(name, tests, beforeFn, afterFn) {
|
(typeof window !== 'undefined' ? window : global).tryTests = function(name, tests, options) {
|
||||||
if (typeof window !== 'undefined' && window.Worker) {
|
if (options.if) {
|
||||||
describe(name, function() {
|
describe(name, function() {
|
||||||
before(beforeFn);
|
if (options.before) { before(options.before); }
|
||||||
|
if (options.beforeEach) { beforeEach(options.beforeEach); }
|
||||||
|
|
||||||
tests();
|
tests();
|
||||||
|
|
||||||
after(afterFn);
|
if (options.afterEach) { afterEach(options.afterEach); }
|
||||||
|
if (options.after) { after(options.after); }
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
describe.skip(name + ' (No Web Worker support --> skipping tests)', tests);
|
describe.skip(name + ' (no support --> skipping tests)', tests);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* globals tryWorker: true */
|
/* globals tryTests: true */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -35,11 +35,15 @@ var pub_key =
|
||||||
var plaintext = 'short message\nnext line\n한국어/조선말';
|
var plaintext = 'short message\nnext line\n한국어/조선말';
|
||||||
var pubKey;
|
var pubKey;
|
||||||
|
|
||||||
tryWorker('Async Proxy', tests, function() {
|
tryTests('Async Proxy', tests, {
|
||||||
openpgp.initWorker({ path:'../dist/openpgp.worker.js' });
|
if: typeof window !== 'undefined' && window.Worker,
|
||||||
pubKey = openpgp.key.readArmored(pub_key).keys[0];
|
before: function() {
|
||||||
}, function() {
|
openpgp.initWorker({ path:'../dist/openpgp.worker.js' });
|
||||||
openpgp.destroyWorker();
|
pubKey = openpgp.key.readArmored(pub_key).keys[0];
|
||||||
|
},
|
||||||
|
after: function() {
|
||||||
|
openpgp.destroyWorker();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function tests() {
|
function tests() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user