Lint all tests (#1235)

This commit is contained in:
Daniel Huigens 2021-02-12 22:27:59 +01:00
parent 8f8517702e
commit b6edfe646b
28 changed files with 806 additions and 775 deletions

View File

@ -1 +1,3 @@
src/compression
dist
test/lib/
test/typescript/definitions.js

View File

@ -44,7 +44,7 @@
"browsertest": "npm start -- -o test/unittests.html",
"browserstack": "karma start test/karma.conf.js",
"coverage": "nyc npm test",
"lint": "eslint 'src/**/*.js' 'test/crypto/**/*.js'",
"lint": "eslint .",
"docs": "jsdoc --configure .jsdocrc.js --destination docs --recurse README.md src",
"preversion": "rm -rf dist docs node_modules && npm install && npm test",
"version": "npm run docs && git add -A docs",

View File

@ -1,3 +1,5 @@
/* eslint-disable no-process-env */
import { builtinModules } from 'module';
import resolve from '@rollup/plugin-node-resolve';
@ -65,7 +67,7 @@ export default Object.assign([
resolve(),
commonjs(),
replace({
'OpenPGP.js VERSION': `OpenPGP.js ${pkg.version}`,
'OpenPGP.js VERSION': `OpenPGP.js ${pkg.version}`
})
]
},
@ -93,7 +95,7 @@ export default Object.assign([
{
input: 'test/unittests.js',
output: [
{ file: 'test/lib/unittests-bundle.js', format: 'es', intro, sourcemap: true },
{ file: 'test/lib/unittests-bundle.js', format: 'es', intro, sourcemap: true }
],
inlineDynamicImports: true,
external: ['../..', '../../..'],

View File

@ -1,11 +1,9 @@
/* eslint-disable import/newline-after-import, import/first */
/**
* Export high level API functions.
* Usage:
*
* import { encrypt } from 'openpgp'
* encrypt({ message, publicKeys })
* import { encrypt } from 'openpgp';
* encrypt({ message, publicKeys });
*/
export {
encrypt, decrypt, sign, verify,

View File

@ -1,4 +1,3 @@
/* eslint-disable callback-return */
/**
* @requires web-stream-tools
* @requires packet/all_packets

View File

@ -9,21 +9,21 @@ module.exports = () => describe("ASCII armor", function() {
function getArmor(headers, signatureHeaders) {
return ['-----BEGIN PGP SIGNED MESSAGE-----']
.concat(headers)
.concat(
['',
.concat([
'',
'sign this',
'-----BEGIN PGP SIGNATURE-----']
)
'-----BEGIN PGP SIGNATURE-----'
])
.concat(signatureHeaders || ['Version: GnuPG v2.0.22 (GNU/Linux)'])
.concat(
['',
.concat([
'',
'iJwEAQECAAYFAlMrPj0ACgkQ4IT3RGwgLJfYkQQAgHMQieazCVdfGAfzQM69Egm5',
'HhcQszODD898wpoGCHgiNdNo1+5nujQAtXnkcxM+Vf7onfbTvUqut/siyO3fzqhK',
'LQ9DiQUwJMBE8nOwVR7Mpc4kLNngMTNaHAjZaVaDpTCrklPY+TPHIZnu0B6Ur+6t',
'skTzzVXIxMYw8ihbHfk=',
'=e/eA',
'-----END PGP SIGNATURE-----']
).join('\n');
'-----END PGP SIGNATURE-----'
]).join('\n');
}
it('Parse cleartext signed message', async function () {
@ -81,8 +81,8 @@ module.exports = () => describe("ASCII armor", function() {
});
it('Filter whitespace in blank line', async function () {
let msg =
['-----BEGIN PGP SIGNED MESSAGE-----',
let msg = [
'-----BEGIN PGP SIGNED MESSAGE-----',
'Hash: SHA1',
' \f\r\t\u00a0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000',
'sign this',
@ -94,7 +94,8 @@ module.exports = () => describe("ASCII armor", function() {
'LQ9DiQUwJMBE8nOwVR7Mpc4kLNngMTNaHAjZaVaDpTCrklPY+TPHIZnu0B6Ur+6t',
'skTzzVXIxMYw8ihbHfk=',
'=e/eA',
'-----END PGP SIGNATURE-----'].join('\n');
'-----END PGP SIGNATURE-----'
].join('\n');
msg = await openpgp.readArmoredCleartextMessage(msg);
expect(msg).to.be.an.instanceof(openpgp.CleartextMessage);
@ -127,8 +128,8 @@ module.exports = () => describe("ASCII armor", function() {
});
it('Exception if wrong armor header type', async function () {
let msg =
['-----BEGIN PGP SIGNED MESSAGE\u2010\u2010\u2010\u2010\u2010\nHash:SHA1\n\nIs this properly-----',
let msg = [
'-----BEGIN PGP SIGNED MESSAGE\u2010\u2010\u2010\u2010\u2010\nHash:SHA1\n\nIs this properly-----',
'',
'sign this',
'-----BEGIN PGP SIGNNATURE-----',
@ -139,15 +140,16 @@ module.exports = () => describe("ASCII armor", function() {
'LQ9DiQUwJMBE8nOwVR7Mpc4kLNngMTNaHAjZaVaDpTCrklPY+TPHIZnu0B6Ur+6t',
'skTzzVXIxMYw8ihbHfk=',
'=e/eA',
'-----END PGP SIGNNATURE-----'].join('\n');
'-----END PGP SIGNNATURE-----'
].join('\n');
msg = openpgp.readArmoredCleartextMessage(msg);
await expect(msg).to.be.rejectedWith(Error, /Unknown ASCII armor type/);
});
it('Armor checksum validation - mismatch', async function () {
const privKey =
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
const privKey = [
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
'Version: OpenPGP.js v0.3.0',
'Comment: https://openpgpjs.org',
'',
@ -164,7 +166,8 @@ module.exports = () => describe("ASCII armor", function() {
'ABMFAlLm1+4JEBD8MASZrpALAhsMAAC3IgD8DnLGbMnpLtrX72RCkPW1ffLq',
'71vlXMJNXvoCeuejiRw=',
'=wJN@',
'-----END PGP PRIVATE KEY BLOCK-----'].join('\n');
'-----END PGP PRIVATE KEY BLOCK-----'
].join('\n');
// try with default config
await expect(openpgp.readArmoredKey(privKey)).to.be.rejectedWith(/Ascii armor integrity check on message failed/);
@ -289,8 +292,8 @@ module.exports = () => describe("ASCII armor", function() {
});
it('Accept header with trailing whitespace', async function () {
const privKey =
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
const privKey = [
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
'Version: OpenPGP.js v0.3.0',
'Comment: https://openpgpjs.org',
'',
@ -308,7 +311,8 @@ module.exports = () => describe("ASCII armor", function() {
'71vlXMJNXvoCeuejiRw=',
'=wJNM',
'-----END PGP PRIVATE KEY BLOCK-----',
''].join('\t \r\n');
''
].join('\t \r\n');
const result = await openpgp.readArmoredKey(privKey);
expect(result).to.be.an.instanceof(openpgp.Key);
@ -321,7 +325,7 @@ module.exports = () => describe("ASCII armor", function() {
});
it('Do not add extraneous blank line when base64 ends on line break', async function () {
let pubKey = `-----BEGIN PGP PUBLIC KEY BLOCK-----
const pubKey = `-----BEGIN PGP PUBLIC KEY BLOCK-----
xsFNBFuR4MABEACoJ9e8zvhj80mFWJzxDErNnD78taGh7hJTs/H1CIIAykjf
NEvTWcnnDI2dsK7J+dBQq9R40G5YYDUvA2dMztqq5BuaUlJvdSiQtqMcirhF

View File

@ -1,4 +1,3 @@
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const random = require('../../src/crypto/random');
const util = require('../../src/util');

View File

@ -13,7 +13,7 @@ module.exports = () => (openpgp.config.ci ? describe.skip : describe)('Brainpool
//only x25519 crypto is fully functional in lightbuild
if (!openpgp.config.useIndutnyElliptic && !util.getNodeCrypto()) {
before(function() {
this.skip();
this.skip(); // eslint-disable-line no-invalid-this
});
}
const data = {
@ -108,7 +108,7 @@ tkYrARUF5n9K9+TEasU4z1k898YkS5cIzFyBSGMhGDzdj7t1K93EyOxXPc84
EJ4QcD/oQ6x1M/8X/iKQCtxZP8RnlrbH7ExkNON5s5g=
=KDoL
-----END PGP MESSAGE-----`,
message_with_leading_zero_in_hash_old_elliptic_implementation: 'test message\n199',
message_with_leading_zero_in_hash_old_elliptic_implementation: 'test message\n199'
},
juliet: {
id: '37e16a986b8af99e',

View File

@ -1,5 +1,3 @@
/* globals tryTests: true */
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const chai = require('chai');
@ -70,7 +68,7 @@ module.exports = () => describe('Elliptic Curve Cryptography for NIST P-256,P-38
it('Sign message', async function () {
const testData = input.createSomeMessage();
let options = { userIds: {name: "Hi", email: "hi@hel.lo"}, curve: "p256" };
const options = { userIds: { name: "Hi", email: "hi@hel.lo" }, curve: "p256" };
const firstKey = await openpgp.generateKey(options);
const signature = await openpgp.sign({ message: openpgp.CleartextMessage.fromText(testData), privateKeys: firstKey.key });
const msg = await openpgp.readArmoredCleartextMessage(signature);
@ -94,7 +92,7 @@ module.exports = () => describe('Elliptic Curve Cryptography for NIST P-256,P-38
{ message: msg,
privateKeys: secondKey.key,
publicKeys: [firstKey.key.toPublic()] }
)
);
expect(result.signatures[0].valid).to.be.true;
});

View File

@ -1,5 +1,3 @@
/* globals tryTests: true */
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const util = require('../../src/util');
@ -11,7 +9,7 @@ const expect = chai.expect;
module.exports = () => describe('Elliptic Curve Cryptography for secp256k1 curve @lightweight', function () {
if (!openpgp.config.useIndutnyElliptic && !util.getNodeCrypto()) {
before(function() {
this.skip();
this.skip(); // eslint-disable-line no-invalid-this
});
}
const data = {

View File

@ -5,7 +5,7 @@ const chai = require('chai');
const { expect } = chai;
module.exports = () => describe.skip('HKP unit tests', function() {
this.timeout(60000);
this.timeout(60000); // eslint-disable-line no-invalid-this
let hkp;
@ -116,7 +116,7 @@ module.exports = () => describe.skip('HKP unit tests', function() {
oNMuvQNShV2G9KkPda3AZWCIWzUBuKN5UuE06u68iclH2ckEicQvnmxHnJU/BSC9
h3bdqlMa87hRGnWluKpJT+XRP0UGiN8UGWo8OEpdz8KbvVTCUVya4g==
=Wjv9
-----END PGP PUBLIC KEY BLOCK-----`
-----END PGP PUBLIC KEY BLOCK-----`;
beforeEach(function() {
hkp = new openpgp.HKP(openpgp.config.keyserver);

View File

@ -1,3 +1,4 @@
/* eslint-disable max-lines */
/* globals tryTests: true */
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
@ -94,7 +95,7 @@ nGHIp2NmbJZnYgl8Ps23qF+LKTa1eE+AmMQYzUHSGuka2lp6OglwWzg/dEw=
=/vbH
-----END PGP PUBLIC KEY BLOCK-----`;
const priv_key_arm4 = `-----BEGIN PGP PRIVATE KEY BLOCK-----
/* const priv_key_arm4 = `-----BEGIN PGP PRIVATE KEY BLOCK-----
Version: GnuPG 2.1.15 (GNU/Linux)
lQIGBFqaDSwBBADKDvHX5y77ws3tYY1nK/LdXzHZ3RUHNXwDO3ZurG6q3ZWgM/g2
@ -128,7 +129,7 @@ uUrp9Qp76CnKqUsUjcVxq7DJBi/lewyGGYSVAFt6/0Xyg/8YTEa/c4Dri/HMOtrf
bgjp/doIVaZLOXZYfqRcpy3z0M6BierOPB3D+fdaTfd7gIrQnGHIp2NmbJZnYgl8
Ps23qF+LKTa1eE+AmMQYzUHSGuka2lp6OglwWzg/dEw=
=mr3M
-----END PGP PRIVATE KEY BLOCK-----`;
-----END PGP PRIVATE KEY BLOCK-----`; */
const revocation_certificate_arm4 = `-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG 2.1.15 (GNU/Linux)
@ -1407,7 +1408,7 @@ cKFQz1DDfFCfVpSIJRGozQ==
-----END PGP PUBLIC KEY BLOCK-----
`;
const revoked_primary_user = `-----BEGIN PGP PUBLIC KEY BLOCK-----
/* const revoked_primary_user = `-----BEGIN PGP PUBLIC KEY BLOCK-----
mQENBE2V9vABCADR6780VEDx0P/Hk+qvGeDkGY/CDKkFIquksfVnWUatmN4mVfcS
yqzmyZ08kAcXQVlU1i+/EeFSQ6vXEP/ZjH9en4YjOGrvmSIrNl4j4vhlJG3Mbao0
@ -1688,7 +1689,7 @@ dh1PTAyfau1IRO3V/ivRaYs32jvMno6zP575CKLJOIyLREm8dbQRRd7h1+ZBxtQf
Jn9lY1FGcIqjyOYanmsOEsSsKZS/exyNIjwi0WRPze+SASRzE/8=
=qfwW
-----END PGP PUBLIC KEY BLOCK-----
`;
`; */
const key_created_2030 = `-----BEGIN PGP PUBLIC KEY BLOCK-----

View File

@ -8,8 +8,8 @@ const keyring = new openpgp.Keyring();
module.exports = () => describe("Keyring", async function() {
const user = 'whiteout.test@t-online.de';
const passphrase = 'asdf';
const keySize = 512;
// const passphrase = 'asdf';
// const keySize = 512;
const keyId = 'f6f60e9b42cdff4c';
const keyFingerP = '5856cef789c3a307e8a1b976f6f60e9b42cdff4c';
const pubkey = '-----BEGIN PGP PUBLIC KEY BLOCK-----\n' +

View File

@ -1,3 +1,4 @@
/* eslint-disable max-lines */
/* globals tryTests: true */
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
@ -12,8 +13,8 @@ chai.use(require('chai-as-promised'));
const expect = chai.expect;
const pub_key =
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
const pub_key = [
'-----BEGIN PGP PUBLIC KEY BLOCK-----',
'Version: GnuPG v2.0.19 (GNU/Linux)',
'',
'mI0EUmEvTgEEANyWtQQMOybQ9JltDqmaX0WnNPJeLILIM36sw6zL0nfTQ5zXSS3+',
@ -35,10 +36,11 @@ const pub_key =
'AtNTq6ihLMD5v1d82ZC7tNatdlDMGWnIdvEMCv2GZcuIqDQ9rXWs49e7tq1NncLY',
'hz3tYjKhoFTKEIq3y3Pp',
'=h/aX',
'-----END PGP PUBLIC KEY BLOCK-----'].join('\n');
'-----END PGP PUBLIC KEY BLOCK-----'
].join('\n');
const priv_key =
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
const priv_key = [
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
'Version: GnuPG v2.0.19 (GNU/Linux)',
'',
'lQH+BFJhL04BBADclrUEDDsm0PSZbQ6pml9FpzTyXiyCyDN+rMOsy9J300Oc10kt',
@ -75,10 +77,11 @@ const priv_key =
'SXuqKcWqoEuO7OBSEFThCXBfUYMC01OrqKEswPm/V3zZkLu01q12UMwZach28QwK',
'/YZly4ioND2tdazj17u2rU2dwtiHPe1iMqGgVMoQirfLc+k=',
'=lw5e',
'-----END PGP PRIVATE KEY BLOCK-----'].join('\n');
'-----END PGP PRIVATE KEY BLOCK-----'
].join('\n');
const pub_key_de =
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
const pub_key_de = [
'-----BEGIN PGP PUBLIC KEY BLOCK-----',
'Version: GnuPG v2.0.22 (GNU/Linux)',
'',
'mQMuBFLVgdQRCACOlpq0cd1IazNjOEpWPZvx/O3JMbdDs3B3iCG0Mo5OUZ8lpKU5',
@ -116,10 +119,11 @@ const pub_key_de =
'y61IhKbJCOlQxyem+kepjNapkhKDAQDIDL38bZWU4Rm0nq82Xb4yaI0BCWDcFkHV',
'og2umGfGng==',
'=v3+L',
'-----END PGP PUBLIC KEY BLOCK-----'].join('\n');
'-----END PGP PUBLIC KEY BLOCK-----'
].join('\n');
const priv_key_de =
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
const priv_key_de = [
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
'Version: GnuPG v2.0.22 (GNU/Linux)',
'',
'lQN5BFLVgdQRCACOlpq0cd1IazNjOEpWPZvx/O3JMbdDs3B3iCG0Mo5OUZ8lpKU5',
@ -160,7 +164,8 @@ const priv_key_de =
'ijpKCgD9HC+RyNOutHhPFbgSvyH3cY6Rbnh1MFAUH3SG4gmiE8kA/A679f/+Izs1',
'DHTORVqAOdoOcu5Qh7AQg1GdSmfFAsx2',
'=kyeP',
'-----END PGP PRIVATE KEY BLOCK-----'].join('\n');
'-----END PGP PRIVATE KEY BLOCK-----'
].join('\n');
const priv_key_2000_2008 = `-----BEGIN PGP PRIVATE KEY BLOCK-----
@ -292,9 +297,9 @@ const passphrase = 'hello world';
const plaintext = input.createSomeMessage();
const password1 = 'I am a password';
const password2 = 'I am another password';
const password3 = 'I am a third password';
const twoPasswordGPGFail = ['-----BEGIN PGP MESSAGE-----',
const twoPasswordGPGFail = [
'-----BEGIN PGP MESSAGE-----',
'Version: OpenPGP.js v3.0.0',
'Comment: https://openpgpjs.org',
'',
@ -304,7 +309,8 @@ const twoPasswordGPGFail = ['-----BEGIN PGP MESSAGE-----',
'migslOF/l6Y9F0F9xGIZWGhxp3ugQPjVKjj8fOH7ap14mLm60C8q8AOxiSmL',
'ubsd/hL7FPZatUYAAZVA0a6hmQ==',
'=cHCV',
'-----END PGP MESSAGE-----'].join('\n');
'-----END PGP MESSAGE-----'
].join('\n');
const ecdh_msg_bad = `-----BEGIN PGP MESSAGE-----
Version: ProtonMail
@ -690,7 +696,7 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
it('should work in JS', function() {
openpgp.config.useNative = false;
const opt = {
userIds: [{ name: 'Test User', email: 'text@example.com' }],
userIds: [{ name: 'Test User', email: 'text@example.com' }]
};
return openpgp.generateKey(opt).then(function(newKey) {
@ -703,7 +709,7 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
it('should work in with native crypto', function() {
openpgp.config.useNative = true;
const opt = {
userIds: [{ name: 'Test User', email: 'text@example.com' }],
userIds: [{ name: 'Test User', email: 'text@example.com' }]
};
return openpgp.generateKey(opt).then(function(newKey) {
@ -1346,7 +1352,7 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
it('should encrypt/sign and decrypt/verify with generated key', function () {
const genOpt = {
userIds: [{ name: 'Test User', email: 'text@example.com' }],
userIds: [{ name: 'Test User', email: 'text@example.com' }]
};
return openpgp.generateKey(genOpt).then(async function(newKey) {
@ -1378,7 +1384,7 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
it('should encrypt/sign and decrypt/verify with generated key and detached signatures', async function () {
const newKey = await openpgp.generateKey({
userIds: [{ name: 'Test User', email: 'text@example.com' }],
userIds: [{ name: 'Test User', email: 'text@example.com' }]
});
const newPublicKey = await openpgp.readArmoredKey(newKey.publicKeyArmored);
const newPrivateKey = await openpgp.readArmoredKey(newKey.privateKeyArmored);
@ -1744,8 +1750,8 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
});
describe("3DES decrypt", function() {
const pgp_msg =
['-----BEGIN PGP MESSAGE-----',
const pgp_msg = [
'-----BEGIN PGP MESSAGE-----',
'Version: GnuPG/MacGPG2 v2.0.19 (Darwin)',
'Comment: GPGTools - https://gpgtools.org',
'',
@ -1755,10 +1761,11 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
'ASm9aZ3H6FerNhm8RezDY5vRn6xw3o/wH5YEBvV2BEmmFKZ2BlqFQxqChr8UNwd1',
'Ieebnq0HtBPE8YU/L0U=',
'=JyIa',
'-----END PGP MESSAGE-----'].join('\n');
'-----END PGP MESSAGE-----'
].join('\n');
const priv_key =
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
const priv_key = [
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
'Version: GnuPG/MacGPG2 v2.0.19 (Darwin)',
'Comment: GPGTools - https://gpgtools.org',
'',
@ -1793,7 +1800,8 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
'CHaOn1Xl2gmYTq2KiJkgtLuwptYU1iSj7vvSHKy0+nYIckOZB4pRCOjknT08O4ZJ',
'22q10ausyQXoOxXfDWVwKA==',
'=IkKW',
'-----END PGP PRIVATE KEY BLOCK-----'].join('\n');
'-----END PGP PRIVATE KEY BLOCK-----'
].join('\n');
it('Decrypt message', async function() {
const privKey = await openpgp.readArmoredKey(priv_key);
@ -1902,14 +1910,14 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
});
it('Streaming encrypt and decrypt small message roundtrip', async function() {
let plaintext = [];
const plaintext = [];
let i = 0;
const useNativeStream = (() => { try { new global.ReadableStream(); return true; } catch (e) { return false; } })();
const useNativeStream = (() => { try { new global.ReadableStream(); return true; } catch (e) { return false; } })(); // eslint-disable-line no-new
const ReadableStream = useNativeStream ? global.ReadableStream : openpgp.stream.ReadableStream;
const data = new ReadableStream({
async pull(controller) {
if (i++ < 4) {
let randomBytes = await random.getRandomBytes(10);
const randomBytes = await random.getRandomBytes(10);
controller.enqueue(randomBytes);
plaintext.push(randomBytes.slice());
} else {
@ -2235,7 +2243,7 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
streaming: 'web',
format: 'binary'
};
const useNativeStream = (() => { try { new global.ReadableStream(); return true; } catch (e) { return false; } })();
const useNativeStream = (() => { try { new global.ReadableStream(); return true; } catch (e) { return false; } })(); // eslint-disable-line no-new
return openpgp.sign(signOpt).then(async function (signed) {
expect(openpgp.stream.isStream(signed)).to.equal(useNativeStream ? 'web' : 'ponyfill');
const message = await openpgp.readMessage(signed);

View File

@ -1,3 +1,5 @@
/* eslint-disable max-lines */
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const crypto = require('../../src/crypto');
const util = require('../../src/util');
@ -8,7 +10,6 @@ chai.use(require('chai-as-promised'));
const { expect } = chai;
const input = require('./testInputs.js');
const { PacketList } = require('../../dist/node/openpgp.min');
function stringify(array) {
if (openpgp.stream.isStream(array)) {
@ -154,7 +155,7 @@ module.exports = () => describe("Packet", function() {
});
it('Sym. encrypted AEAD protected packet (AEAD)', async function() {
let aeadProtectVal = openpgp.config.aeadProtect;
const aeadProtectVal = openpgp.config.aeadProtect;
openpgp.config.aeadProtect = true;
const testText = input.createSomeMessage();
@ -188,14 +189,14 @@ module.exports = () => describe("Packet", function() {
cryptStub.onCall(0).callsFake(async function() {
cryptCallsActive++;
try {
return await crypt.apply(this, arguments);
return await crypt.apply(this, arguments); // eslint-disable-line no-invalid-this
} finally {
cryptCallsActive--;
}
});
cryptStub.onCall(1).callsFake(function() {
expect(cryptCallsActive).to.equal(1);
return crypt.apply(this, arguments);
return crypt.apply(this, arguments); // eslint-disable-line no-invalid-this
});
cryptStub.callThrough();
return cryptStub;
@ -207,8 +208,8 @@ module.exports = () => describe("Packet", function() {
const encryptStub = cryptStub(webCrypto, 'encrypt');
const decryptStub = cryptStub(webCrypto, 'decrypt');
let aeadProtectVal = openpgp.config.aeadProtect;
let aeadChunkSizeByteVal = openpgp.config.aeadChunkSizeByte;
const aeadProtectVal = openpgp.config.aeadProtect;
const aeadChunkSizeByteVal = openpgp.config.aeadChunkSizeByte;
openpgp.config.aeadProtect = true;
openpgp.config.aeadChunkSizeByte = 0;
const testText = input.createSomeMessage();
@ -248,7 +249,7 @@ module.exports = () => describe("Packet", function() {
const nodeCrypto = util.getNodeCrypto();
if (!nodeCrypto) return;
let packetBytes = util.hexToUint8Array(`
const packetBytes = util.hexToUint8Array(`
d4 4a 01 07 01 0e b7 32 37 9f 73 c4 92 8d e2 5f
ac fe 65 17 ec 10 5d c1 1a 81 dc 0c b8 a2 f6 f3
d9 00 16 38 4a 56 fc 82 1a e1 1a e8 db cb 49 86
@ -256,8 +257,8 @@ module.exports = () => describe("Packet", function() {
ab 01 3d e1 25 95 86 90 6e ab 24 76
`.replace(/\s+/g, ''));
let aeadProtectVal = openpgp.config.aeadProtect;
let aeadChunkSizeByteVal = openpgp.config.aeadChunkSizeByte;
const aeadProtectVal = openpgp.config.aeadProtect;
const aeadChunkSizeByteVal = openpgp.config.aeadChunkSizeByte;
openpgp.config.aeadProtect = true;
openpgp.config.aeadChunkSizeByte = 14;
@ -276,7 +277,7 @@ module.exports = () => describe("Packet", function() {
const msg2 = new openpgp.PacketList();
let randomBytesStub = stub(nodeCrypto, 'randomBytes');
const randomBytesStub = stub(nodeCrypto, 'randomBytes');
randomBytesStub.returns(iv);
try {
@ -485,7 +486,7 @@ module.exports = () => describe("Packet", function() {
});
it('Sym. encrypted session key reading/writing (AEAD)', async function() {
let aeadProtectVal = openpgp.config.aeadProtect;
const aeadProtectVal = openpgp.config.aeadProtect;
openpgp.config.aeadProtect = true;
try {
@ -529,25 +530,25 @@ module.exports = () => describe("Packet", function() {
const nodeCrypto = util.getNodeCrypto();
if (!nodeCrypto) return;
let aeadProtectVal = openpgp.config.aeadProtect;
let aeadChunkSizeByteVal = openpgp.config.aeadChunkSizeByte;
let s2kIterationCountByteVal = openpgp.config.s2kIterationCountByte;
const aeadProtectVal = openpgp.config.aeadProtect;
const aeadChunkSizeByteVal = openpgp.config.aeadChunkSizeByte;
const s2kIterationCountByteVal = openpgp.config.s2kIterationCountByte;
openpgp.config.aeadProtect = true;
openpgp.config.aeadChunkSizeByte = 14;
openpgp.config.s2kIterationCountByte = 0x90;
let salt = util.hexToUint8Array(`cd5a9f70fbe0bc65`);
let sessionKey = util.hexToUint8Array(`86 f1 ef b8 69 52 32 9f 24 ac d3 bf d0 e5 34 6d`.replace(/\s+/g, ''));
let sessionIV = util.hexToUint8Array(`bc 66 9e 34 e5 00 dc ae dc 5b 32 aa 2d ab 02 35`.replace(/\s+/g, ''));
let dataIV = util.hexToUint8Array(`b7 32 37 9f 73 c4 92 8d e2 5f ac fe 65 17 ec 10`.replace(/\s+/g, ''));
const salt = util.hexToUint8Array(`cd5a9f70fbe0bc65`);
const sessionKey = util.hexToUint8Array(`86 f1 ef b8 69 52 32 9f 24 ac d3 bf d0 e5 34 6d`.replace(/\s+/g, ''));
const sessionIV = util.hexToUint8Array(`bc 66 9e 34 e5 00 dc ae dc 5b 32 aa 2d ab 02 35`.replace(/\s+/g, ''));
const dataIV = util.hexToUint8Array(`b7 32 37 9f 73 c4 92 8d e2 5f ac fe 65 17 ec 10`.replace(/\s+/g, ''));
let randomBytesStub = stub(nodeCrypto, 'randomBytes');
const randomBytesStub = stub(nodeCrypto, 'randomBytes');
randomBytesStub.onCall(0).returns(salt);
randomBytesStub.onCall(1).returns(sessionKey);
randomBytesStub.onCall(2).returns(sessionIV);
randomBytesStub.onCall(3).returns(dataIV);
let packetBytes = util.hexToUint8Array(`
const packetBytes = util.hexToUint8Array(`
c3 3e 05 07 01 03 08 cd 5a 9f 70 fb e0 bc 65 90
bc 66 9e 34 e5 00 dc ae dc 5b 32 aa 2d ab 02 35
9d ee 19 d0 7c 34 46 c4 31 2a 34 ae 19 67 a2 fb
@ -607,25 +608,25 @@ module.exports = () => describe("Packet", function() {
const nodeCrypto = util.getNodeCrypto();
if (!nodeCrypto) return;
let aeadProtectVal = openpgp.config.aeadProtect;
let aeadChunkSizeByteVal = openpgp.config.aeadChunkSizeByte;
let s2kIterationCountByteVal = openpgp.config.s2kIterationCountByte;
const aeadProtectVal = openpgp.config.aeadProtect;
const aeadChunkSizeByteVal = openpgp.config.aeadChunkSizeByte;
const s2kIterationCountByteVal = openpgp.config.s2kIterationCountByte;
openpgp.config.aeadProtect = true;
openpgp.config.aeadChunkSizeByte = 14;
openpgp.config.s2kIterationCountByte = 0x90;
let salt = util.hexToUint8Array(`9f0b7da3e5ea6477`);
let sessionKey = util.hexToUint8Array(`d1 f0 1b a3 0e 13 0a a7 d2 58 2c 16 e0 50 ae 44`.replace(/\s+/g, ''));
let sessionIV = util.hexToUint8Array(`99 e3 26 e5 40 0a 90 93 6c ef b4 e8 eb a0 8c`.replace(/\s+/g, ''));
let dataIV = util.hexToUint8Array(`5e d2 bc 1e 47 0a be 8f 1d 64 4c 7a 6c 8a 56`.replace(/\s+/g, ''));
const salt = util.hexToUint8Array(`9f0b7da3e5ea6477`);
const sessionKey = util.hexToUint8Array(`d1 f0 1b a3 0e 13 0a a7 d2 58 2c 16 e0 50 ae 44`.replace(/\s+/g, ''));
const sessionIV = util.hexToUint8Array(`99 e3 26 e5 40 0a 90 93 6c ef b4 e8 eb a0 8c`.replace(/\s+/g, ''));
const dataIV = util.hexToUint8Array(`5e d2 bc 1e 47 0a be 8f 1d 64 4c 7a 6c 8a 56`.replace(/\s+/g, ''));
let randomBytesStub = stub(nodeCrypto, 'randomBytes');
const randomBytesStub = stub(nodeCrypto, 'randomBytes');
randomBytesStub.onCall(0).returns(salt);
randomBytesStub.onCall(1).returns(sessionKey);
randomBytesStub.onCall(2).returns(sessionIV);
randomBytesStub.onCall(3).returns(dataIV);
let packetBytes = util.hexToUint8Array(`
const packetBytes = util.hexToUint8Array(`
c3 3d 05 07 02 03 08 9f 0b 7d a3 e5 ea 64 77 90
99 e3 26 e5 40 0a 90 93 6c ef b4 e8 eb a0 8c 67
73 71 6d 1f 27 14 54 0a 38 fc ac 52 99 49 da c5

View File

@ -1,3 +1,6 @@
/* eslint-disable max-lines */
/* globals tryTests: true */
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const util = require('../../src/util');
@ -658,8 +661,8 @@ Blk+CJ7ytHy6En8542bB/yC+Z9/zWbVuhg==
=jmT1
-----END PGP PUBLIC KEY BLOCK-----`;
const msg_sig_expired =
['-----BEGIN PGP MESSAGE-----',
const msg_sig_expired = [
'-----BEGIN PGP MESSAGE-----',
'Comment: GPGTools - https://gpgtools.org',
'',
'owEBWwKk/ZANAwAKAeyAexA3gWZ0AawUYgloZWxsby50eHRaX2WpaGVsbG+JAjME',
@ -676,10 +679,11 @@ Blk+CJ7ytHy6En8542bB/yC+Z9/zWbVuhg==
'kLlUC1zKjFPpRhO27ImTJuImil4lR2/CFjB1duG3JGJQaYIq8RFJOjvTVY29wl0i',
'pFy6y1Ofv2lLHB9K7N7dvvee2nvpUMkLEL52oFQ6Jc7sdg==',
'=Q4tk',
'-----END PGP MESSAGE-----'].join('\n');
'-----END PGP MESSAGE-----'
].join('\n');
const flowcrypt_stripped_key =
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
const flowcrypt_stripped_key = [
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
'',
'lQIVBFttsQgBEADZT3v1LUGqP/hhUWmjfHVh6MErZAqsmbUIgsUKCDpQ4hrRpot2',
'V3ZIMbbEGSjbUvyT/2quAtLRHx9/FK1MA3q0qVrUGmiXx78IiAuQ7sZOTjYXBDnq',
@ -820,7 +824,8 @@ Blk+CJ7ytHy6En8542bB/yC+Z9/zWbVuhg==
'hBr9NrB2VFHtdaWf2YqBGb7c1xusmEuGLcGUqFGCXo/g/lOSPijea91puCf9bgKy',
'0P7n+O0V3W1QpkI4ne5TE2vBFUFo9K5IFe4qBI1JPjbLTfOI2lojx8P12+lqWug=',
'=NbaL',
'-----END PGP PRIVATE KEY BLOCK-----'].join("\n");
'-----END PGP PRIVATE KEY BLOCK-----'
].join("\n");
const signature_with_critical_notation = `-----BEGIN PGP MESSAGE-----
@ -1484,7 +1489,7 @@ hkJiXopCSWKSlQInL1devkJJUWJmTmZeugJYlpdLAagQJM0JpsCqIQZwKgAA
await Promise.all([privKey.primaryKey.decrypt('hello world'), privKey.subKeys[0].keyPacket.decrypt('hello world')]);
return openpgp.sign({ privateKeys:[privKey], message: openpgp.Message.fromText(plaintext), detached: true }).then(async function(signed) {
const signature = await openpgp.readArmoredSignature(signed);
return openpgp.encrypt({ message: openpgp.Message.fromBinary(util.encodeUtf8(plaintext)), publicKeys: [pubKey], signature })
return openpgp.encrypt({ message: openpgp.Message.fromBinary(util.encodeUtf8(plaintext)), publicKeys: [pubKey], signature });
}).then(async data => {
const csMsg = await openpgp.readArmoredMessage(data);
return openpgp.decrypt({ message: csMsg, privateKeys: [privKey], publicKeys: [pubKey] });
@ -1697,9 +1702,9 @@ iTuGu4fEU1UligAXSrZmCdE=
-----END PGP PUBLIC KEY BLOCK-----`;
const key = await openpgp.readArmoredKey(armoredKeyWithPhoto);
for (const user of key.users) {
await Promise.all(key.users.map(async user => {
await user.verify(key.primaryKey);
}
}));
});
it('should verify a shorter RSA signature', async function () {

View File

@ -1,3 +1,6 @@
/* eslint-disable max-lines */
/* globals tryTests: true */
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const random = require('../../src/crypto/random');
const util = require('../../src/util');
@ -11,11 +14,11 @@ const { expect } = chai;
const { stream } = openpgp;
const useNativeStream = (() => { try { new global.ReadableStream(); return true; } catch (e) { return false; } })();
const useNativeStream = (() => { try { new global.ReadableStream(); return true; } catch (e) { return false; } })(); // eslint-disable-line no-new
const ReadableStream = useNativeStream ? global.ReadableStream : openpgp.stream.ReadableStream;
const pub_key =
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
const pub_key = [
'-----BEGIN PGP PUBLIC KEY BLOCK-----',
'Version: GnuPG v2.0.19 (GNU/Linux)',
'',
'mI0EUmEvTgEEANyWtQQMOybQ9JltDqmaX0WnNPJeLILIM36sw6zL0nfTQ5zXSS3+',
@ -37,10 +40,11 @@ const pub_key =
'AtNTq6ihLMD5v1d82ZC7tNatdlDMGWnIdvEMCv2GZcuIqDQ9rXWs49e7tq1NncLY',
'hz3tYjKhoFTKEIq3y3Pp',
'=h/aX',
'-----END PGP PUBLIC KEY BLOCK-----'].join('\n');
'-----END PGP PUBLIC KEY BLOCK-----'
].join('\n');
const priv_key =
['-----BEGIN PGP PRIVATE KEY BLOCK-----',
const priv_key = [
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
'Version: GnuPG v2.0.19 (GNU/Linux)',
'',
'lQH+BFJhL04BBADclrUEDDsm0PSZbQ6pml9FpzTyXiyCyDN+rMOsy9J300Oc10kt',
@ -77,7 +81,8 @@ const priv_key =
'SXuqKcWqoEuO7OBSEFThCXBfUYMC01OrqKEswPm/V3zZkLu01q12UMwZach28QwK',
'/YZly4ioND2tdazj17u2rU2dwtiHPe1iMqGgVMoQirfLc+k=',
'=lw5e',
'-----END PGP PRIVATE KEY BLOCK-----'].join('\n');
'-----END PGP PRIVATE KEY BLOCK-----'
].join('\n');
const passphrase = 'hello world';
@ -165,7 +170,14 @@ const xPriv = [
const xPass = 'sun';
let privKey, pubKey, plaintext, data, i, canceled, expectedType, dataArrived;
let privKey;
let pubKey;
let plaintext;
let data;
let i;
let canceled;
let expectedType;
let dataArrived;
function tests() {
it('Encrypt small message', async function() {
@ -179,7 +191,7 @@ function tests() {
});
const encrypted = await openpgp.encrypt({
message: openpgp.Message.fromBinary(data),
passwords: ['test'],
passwords: ['test']
});
const msgAsciiArmored = await openpgp.stream.readToEnd(encrypted);
const message = await openpgp.readArmoredMessage(msgAsciiArmored);
@ -193,7 +205,7 @@ function tests() {
it('Encrypt larger message', async function() {
const encrypted = await openpgp.encrypt({
message: openpgp.Message.fromBinary(data),
passwords: ['test'],
passwords: ['test']
});
const reader = openpgp.stream.getReader(encrypted);
expect(await reader.peekBytes(1024)).to.match(/^-----BEGIN PGP MESSAGE-----\n/);
@ -212,7 +224,7 @@ function tests() {
it('Input stream should be canceled when canceling encrypted stream', async function() {
const encrypted = await openpgp.encrypt({
message: openpgp.Message.fromBinary(data),
passwords: ['test'],
passwords: ['test']
});
const reader = openpgp.stream.getReader(encrypted);
expect(await reader.readBytes(1024)).to.match(/^-----BEGIN PGP MESSAGE-----\n/);
@ -236,7 +248,7 @@ function tests() {
});
it('Encrypt and decrypt larger message roundtrip', async function() {
let aeadProtectValue = openpgp.config.aeadProtect;
const aeadProtectValue = openpgp.config.aeadProtect;
openpgp.config.aeadProtect = false;
const encrypted = await openpgp.encrypt({
message: openpgp.Message.fromBinary(data),
@ -261,8 +273,8 @@ function tests() {
});
it('Encrypt and decrypt larger message roundtrip (allowUnauthenticatedStream=true)', async function() {
let aeadProtectValue = openpgp.config.aeadProtect;
let allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
const aeadProtectValue = openpgp.config.aeadProtect;
const allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
openpgp.config.aeadProtect = false;
openpgp.config.allowUnauthenticatedStream = true;
try {
@ -293,7 +305,7 @@ function tests() {
});
it('Encrypt and decrypt larger message roundtrip using public keys (allowUnauthenticatedStream=true)', async function() {
let allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
const allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
openpgp.config.allowUnauthenticatedStream = true;
try {
const encrypted = await openpgp.encrypt({
@ -322,7 +334,7 @@ function tests() {
});
it('Encrypt and decrypt larger message roundtrip using curve x25519 (allowUnauthenticatedStream=true)', async function() {
let allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
const allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
openpgp.config.allowUnauthenticatedStream = true;
const priv = await openpgp.readArmoredKey(xPriv);
const pub = await openpgp.readArmoredKey(xPub);
@ -354,7 +366,7 @@ function tests() {
});
it('Encrypt and decrypt larger message roundtrip using curve brainpool (allowUnauthenticatedStream=true)', async function() {
let allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
const allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
openpgp.config.allowUnauthenticatedStream = true;
const priv = await openpgp.readArmoredKey(brainpoolPriv);
const pub = await openpgp.readArmoredKey(brainpoolPub);
@ -386,9 +398,9 @@ function tests() {
});
it('Detect MDC modifications (allowUnauthenticatedStream=true)', async function() {
let aeadProtectValue = openpgp.config.aeadProtect;
const aeadProtectValue = openpgp.config.aeadProtect;
openpgp.config.aeadProtect = false;
let allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
const allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
openpgp.config.allowUnauthenticatedStream = true;
try {
const encrypted = await openpgp.encrypt({
@ -423,7 +435,7 @@ function tests() {
});
it('Detect armor checksum error (allowUnauthenticatedStream=true)', async function() {
let allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
const allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
openpgp.config.allowUnauthenticatedStream = true;
try {
const encrypted = await openpgp.encrypt({
@ -458,7 +470,7 @@ function tests() {
});
it('Detect armor checksum error when not passing public keys (allowUnauthenticatedStream=true)', async function() {
let allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
const allowUnauthenticatedStreamValue = openpgp.config.allowUnauthenticatedStream;
openpgp.config.allowUnauthenticatedStream = true;
try {
const encrypted = await openpgp.encrypt({
@ -802,13 +814,13 @@ function tests() {
it('Encrypt and decrypt larger text message roundtrip (AEAD)', async function() {
openpgp.config.aeadChunkSizeByte = 0;
let plaintext = [];
const plaintext = [];
let i = 0;
const data = new ReadableStream({
async pull(controller) {
await new Promise(resolve => setTimeout(resolve, 10));
if (i++ < 10) {
let randomData = input.createSomeMessage();
const randomData = input.createSomeMessage();
controller.enqueue(randomData);
plaintext.push(randomData);
} else {
@ -875,7 +887,7 @@ function tests() {
it('Input stream should be canceled when canceling decrypted stream (AEAD)', async function() {
const encrypted = await openpgp.encrypt({
message: openpgp.Message.fromBinary(data),
passwords: ['test'],
passwords: ['test']
});
const message = await openpgp.readArmoredMessage(encrypted);
@ -905,9 +917,9 @@ module.exports = () => describe('Streaming', function() {
});
beforeEach(function() {
let test = ++currentTest;
const test = ++currentTest;
let dataArrivedPromise = new Promise(resolve => {
const dataArrivedPromise = new Promise(resolve => {
dataArrived = resolve;
});
plaintext = [];
@ -918,7 +930,7 @@ module.exports = () => describe('Streaming', function() {
await new Promise(setTimeout);
if (test === currentTest && i++ < 100) {
if (i === 4) await dataArrivedPromise;
let randomBytes = await random.getRandomBytes(1024);
const randomBytes = await random.getRandomBytes(1024);
controller.enqueue(randomBytes);
plaintext.push(randomBytes);
} else {
@ -951,7 +963,7 @@ module.exports = () => describe('Streaming', function() {
it('Node: Encrypt and decrypt text message roundtrip', async function() {
dataArrived(); // Do not wait until data arrived.
const plaintext = fs.readFileSync(__filename.replace('streaming.js', 'openpgp.js'), 'utf8');
const plaintext = fs.readFileSync(__filename.replace('streaming.js', 'openpgp.js'), 'utf8'); // eslint-disable-line no-sync
const data = fs.createReadStream(__filename.replace('streaming.js', 'openpgp.js'), { encoding: 'utf8' });
const encrypted = await openpgp.encrypt({
message: openpgp.Message.fromText(data),
@ -970,7 +982,7 @@ module.exports = () => describe('Streaming', function() {
it('Node: Encrypt and decrypt binary message roundtrip', async function() {
dataArrived(); // Do not wait until data arrived.
const plaintext = fs.readFileSync(__filename.replace('streaming.js', 'openpgp.js'));
const plaintext = fs.readFileSync(__filename.replace('streaming.js', 'openpgp.js')); // eslint-disable-line no-sync
const data = fs.createReadStream(__filename.replace('streaming.js', 'openpgp.js'));
const encrypted = await openpgp.encrypt({
message: openpgp.Message.fromBinary(data),

View File

@ -1,4 +1,3 @@
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const util = require('../../src/util');
const chai = require('chai');
@ -42,7 +41,7 @@ module.exports = () => describe('Util unit tests', function() {
expect(util.isArray(data)).to.be.true;
});
it('should return true for type Array', function() {
const data = Array();
const data = Array(); // eslint-disable-line no-array-constructor
expect(util.isArray(data)).to.be.true;
});
it('should return true for inherited type of Array', function() {
@ -144,7 +143,7 @@ module.exports = () => describe('Util unit tests', function() {
describe("Misc.", function() {
it('util.readNumber should not overflow until full range of uint32', function () {
const ints = [Math.pow(2, 20), Math.pow(2, 25), Math.pow(2, 30), Math.pow(2, 32) - 1];
const ints = [2 ** 20, 2 ** 25, 2 ** 30, 2 ** 32 - 1];
for (let i = 0; i < ints.length; i++) {
expect(util.readNumber(util.writeNumber(ints[i], 4))).to.equal(ints[i]);
}
@ -155,7 +154,7 @@ module.exports = () => describe('Util unit tests', function() {
it('util.encodeZBase32 encodes correctly', function() {
const encoded = util.encodeZBase32(util.strToUint8Array('test-wkd'));
expect(encoded).to.equal('qt1zg7bpq7ise');
})
})
});
});
});

View File

@ -4,6 +4,7 @@ const chai = require('chai');
const { expect } = chai;
/* eslint-disable no-invalid-this */
module.exports = () => describe.skip('WKD unit tests', function() {
this.timeout(60000);

View File

@ -1,3 +1,5 @@
/* eslint-disable no-process-env */
module.exports = function(config) {
config.set({
@ -36,13 +38,13 @@ module.exports = function(config) {
{
pattern: 'test/**/*',
included: false
},
}
],
proxies: {
'/lib': '/base/test/lib',
'/worker': '/base/test/worker',
'/dist': '/base/dist',
'/dist': '/base/dist'
},
// list of files to exclude
@ -109,7 +111,7 @@ module.exports = function(config) {
real_mobile: true,
os: 'ios',
os_version: '12'
},
}
},
captureTimeout: 6e5,
@ -124,7 +126,7 @@ module.exports = function(config) {
'bs_firefox_68',
'bs_chrome_68',
'bs_safari_11_1',
'bs_ios_12',
'bs_ios_12'
],
// Continuous Integration mode

View File

@ -68,7 +68,7 @@ fhGyl7nA7UCwgsqf7ZPBhRg=
=nbjQ
-----END PGP SIGNATURE-----`;
async function getOtherPubKey() {
return await readArmoredKey(OTHERPUBKEY);
return readArmoredKey(OTHERPUBKEY);
}
/**

View File

@ -1,7 +1,5 @@
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
const { key, cleartext, enums, PacketList, SignaturePacket } = openpgp;
const chai = require('chai');
chai.use(require('chai-as-promised'));

View File

@ -49,7 +49,7 @@ Dc2vwS83Aja9iWrIEg==
-----END PGP PRIVATE KEY BLOCK-----`;
async function getInvalidKey() {
return await readArmoredKey(INVALID_KEY);
return readArmoredKey(INVALID_KEY);
}
async function makeKeyValid() {
/**

View File

@ -1,3 +1,5 @@
/* globals openpgp: true */
(typeof window !== 'undefined' ? window : global).globalThis = (typeof window !== 'undefined' ? window : global);
(typeof window !== 'undefined' ? window : global).resolves = function(val) {
@ -34,7 +36,7 @@ describe('Unit Tests', function () {
if (key && key !== 'grep') {
openpgp.config[key] = decodeURIComponent(value);
try {
openpgp.config[key] = window.eval(openpgp.config[key]);
openpgp.config[key] = window.eval(openpgp.config[key]); // eslint-disable-line no-eval
} catch (e) {}
}
});

View File

@ -18,7 +18,7 @@ function tests() {
try {
globalThis.eval('(async function() {})');
} catch (e) {
console.error(e);
console.error(e); // eslint-disable-line no-console
this.skip();
}
const worker = new Worker('./worker/worker_example.js');

View File

@ -1,3 +1,5 @@
/* globals openpgp: true */
importScripts('../../dist/openpgp.js');
const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----
@ -71,7 +73,7 @@ onmessage = async function({ data: { action, message }, ports: [port] }) {
}
port.postMessage({ result });
} catch (e) {
console.error(e);
console.error(e); // eslint-disable-line no-console
port.postMessage({ error: e.message });
}
};