From 318d86e5e9944718e895d12a1d6c7993a1fd93ae Mon Sep 17 00:00:00 2001 From: Bart Butler Date: Tue, 28 Nov 2017 10:18:26 -0800 Subject: [PATCH] do not use arrow syntax for tests (old node/browser versions) --- test/general/hkp.js | 8 ++-- test/general/key.js | 20 ++++----- test/general/openpgp.js | 84 +++++++++++++++++++------------------- test/general/packet.js | 8 ++-- test/general/signature.js | 20 ++++----- test/worker/async_proxy.js | 2 +- 6 files changed, 71 insertions(+), 71 deletions(-) diff --git a/test/general/hkp.js b/test/general/hkp.js index 084bb657..4d0df07f 100644 --- a/test/general/hkp.js +++ b/test/general/hkp.js @@ -113,7 +113,7 @@ describe('HKP unit tests', function() { afterEach(function() {}); describe('lookup', function() { - it('by email address should work', () => { + it('by email address should work', function() { return hkp.lookup({ query: 'safewithme.testuser@gmail.com' }).then(function(key) { @@ -121,7 +121,7 @@ describe('HKP unit tests', function() { }); }); - it('by email address should not find a key', () => { + it('by email address should not find a key', function() { return hkp.lookup({ query: 'safewithme.testuse@gmail.com' }).then(function(key) { @@ -129,7 +129,7 @@ describe('HKP unit tests', function() { }); }); - it('by key id should work', () => { + it('by key id should work', function() { return hkp.lookup({ keyId: 'D7FB93FCDFBFC23C' }).then(function(key) { @@ -139,7 +139,7 @@ describe('HKP unit tests', function() { }); describe('upload', function() { - it('should work', () => { + it('should work', function() { return hkp.upload(pub_key); }); }); diff --git a/test/general/key.js b/test/general/key.js index eb06c53d..e97a6600 100644 --- a/test/general/key.js +++ b/test/general/key.js @@ -885,7 +885,7 @@ describe('Key', function() { expect(prefAlgo).to.equal(openpgp.config.encryption_cipher); }); - it('Preferences of generated key', () => { + it('Preferences of generated key', function() { var testPref = function(key) { // key flags var keyFlags = openpgp.enums.keyFlags; @@ -923,7 +923,7 @@ describe('Key', function() { expect(primUser.selfCertificate).to.be.an.instanceof(openpgp.packet.Signature); }); - it('Generated key is not unlocked by default', () => { + it('Generated key is not unlocked by default', function() { var opt = {numBits: 512, userIds: 'test ', passphrase: '123'}; if (openpgp.util.getWebCryptoAll()) { opt.numBits = 2048; } // webkit webcrypto accepts minimum 2048 bit keys var key; @@ -937,7 +937,7 @@ describe('Key', function() { }); }); - it('Generate key - single userid', () => { + it('Generate key - single userid', function() { var userId = 'test '; var opt = {numBits: 512, userIds: userId, passphrase: '123'}; if (openpgp.util.getWebCryptoAll()) { opt.numBits = 2048; } // webkit webcrypto accepts minimum 2048 bit keys @@ -948,7 +948,7 @@ describe('Key', function() { }); }); - it('Generate key - multi userid', () => { + it('Generate key - multi userid', function() { var userId1 = 'test '; var userId2 = 'test '; var opt = {numBits: 512, userIds: [userId1, userId2], passphrase: '123'}; @@ -963,7 +963,7 @@ describe('Key', function() { }); }); - it('Encrypt key with new passphrase', () => { + it('Encrypt key with new passphrase', function() { var userId = 'test '; var opt = {numBits: 512, userIds: userId, passphrase: 'passphrase'}; if (openpgp.util.getWebCryptoAll()) { opt.numBits = 2048; } // webkit webcrypto accepts minimum 2048 bit keys @@ -985,7 +985,7 @@ describe('Key', function() { }); }); - it('Generate key - ensure keyExpirationTime works', () => { + it('Generate key - ensure keyExpirationTime works', function() { var expect_delta = 365 * 24 * 60 * 60; var userId = 'test '; var opt = {numBits: 512, userIds: userId, passphrase: '123', keyExpirationTime: expect_delta}; @@ -1080,7 +1080,7 @@ describe('Key', function() { expect(signatures[3].valid).to.be.null; done(); }); - it('Reformat key without passphrase', () => { + it('Reformat key without passphrase', function() { var userId1 = 'test1 '; var userId2 = 'test2 '; var opt = {numBits: 512, userIds: userId1}; @@ -1101,7 +1101,7 @@ describe('Key', function() { }); }); - it('Reformat and encrypt key', () => { + it('Reformat and encrypt key', function() { var userId1 = 'test1 '; var userId2 = 'test2 '; var userId3 = 'test3 '; @@ -1123,7 +1123,7 @@ describe('Key', function() { }); }); - it('Sign and encrypt with reformatted key', () => { + it('Sign and encrypt with reformatted key', function() { var userId1 = 'test1 '; var userId2 = 'test2 '; var opt = {numBits: 512, userIds: userId1}; @@ -1144,7 +1144,7 @@ describe('Key', function() { }); }); - it('Throw user friendly error when reformatting encrypted key', () => { + it('Throw user friendly error when reformatting encrypted key', function() { return openpgp.generateKey({numBits: 1024, userIds: 'test1 ', passphrase: '1234'}).then(function(original) { return openpgp.reformatKey({privateKey: original.key, userIds: 'test2 ', passphrase: '1234'}).then(function() { throw new Error('reformatKey should result in error when key not decrypted'); diff --git a/test/general/openpgp.js b/test/general/openpgp.js index 17b8bed9..e3481b2d 100644 --- a/test/general/openpgp.js +++ b/test/general/openpgp.js @@ -250,49 +250,49 @@ describe('OpenPGP.js public api tests', function() { expect(test).to.throw(/Invalid user id format/); }); - it('should work for valid single string user id', () => { + it('should work for valid single string user id', function() { var opt = { userIds: 'Test User ' }; return openpgp.generateKey(opt); }); - it('should work for valid string user id', () => { + it('should work for valid string user id', function() { var opt = { userIds: ['Test User '] }; return openpgp.generateKey(opt); }); - it('should work for valid single user id hash', () => { + it('should work for valid single user id hash', function() { var opt = { userIds: { name: 'Test User', email: 'text@example.com' } }; return openpgp.generateKey(opt); }); - it('should work for valid single user id hash', () => { + it('should work for valid single user id hash', function() { var opt = { userIds: [{ name: 'Test User', email: 'text@example.com' }] }; return openpgp.generateKey(opt); }); - it('should work for an empty name', () => { + it('should work for an empty name', function() { var opt = { userIds: { email: 'text@example.com' } }; return openpgp.generateKey(opt); }); - it('should work for an empty email address', () => { + it('should work for an empty email address', function() { var opt = { userIds: { name: 'Test User' } }; return openpgp.generateKey(opt); }); - it('should have default params set', () => { + it('should have default params set', function() { var opt = { userIds: { name: 'Test User', email: 'text@example.com' }, passphrase: 'secret', @@ -312,7 +312,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should work for no params', () => { + it('should work for no params', function() { return openpgp.generateKey().then(function(newKey) { expect(keyGenStub.withArgs({ userIds: [], @@ -353,7 +353,7 @@ describe('OpenPGP.js public api tests', function() { openpgp.destroyWorker(); }); - it('should work in JS (without worker)', () => { + it('should work in JS (without worker)', function() { openpgp.config.use_native = false; openpgp.destroyWorker(); var opt = { @@ -368,7 +368,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should work in JS (with worker)', () => { + it('should work in JS (with worker)', function() { openpgp.config.use_native = false; openpgp.initWorker({ path:'../dist/openpgp.worker.js' }); var opt = { @@ -383,7 +383,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should work in with native crypto', () => { + it('should work in with native crypto', function() { openpgp.config.use_native = true; var opt = { userIds: [{ name: 'Test User', email: 'text@example.com' }], @@ -459,7 +459,7 @@ describe('OpenPGP.js public api tests', function() { }); function tests() { - it('Configuration', () => { + it('Configuration', function() { openpgp.config.show_version = false; openpgp.config.commentstring = 'different'; if (openpgp.getWorker()) { // init again to trigger config event @@ -472,7 +472,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('Calling decrypt with not decrypted key leads to exception', () => { + it('Calling decrypt with not decrypted key leads to exception', function() { var encOpt = { data: plaintext, publicKeys: publicKey.keys, @@ -489,7 +489,7 @@ describe('OpenPGP.js public api tests', function() { }); describe('decryptKey', function() { - it('should work for correct passphrase', () => { + it('should work for correct passphrase', function() { return openpgp.decryptKey({ privateKey: privateKey.keys[0], passphrase: passphrase @@ -499,7 +499,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should fail for incorrect passphrase', () => { + it('should fail for incorrect passphrase', function() { return openpgp.decryptKey({ privateKey: privateKey.keys[0], passphrase: 'incorrect' @@ -516,7 +516,7 @@ describe('OpenPGP.js public api tests', function() { expect(privateKey.keys[0].decrypt(passphrase)).to.be.true; }); - it('should encrypt with public key', () => { + it('should encrypt with public key', function() { return openpgp.encryptSessionKey({ data: sk, algorithm: 'aes128', @@ -531,7 +531,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should encrypt with password', () => { + it('should encrypt with password', function() { return openpgp.encryptSessionKey({ data: sk, algorithm: 'aes128', @@ -546,7 +546,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('roundtrip workflow: encrypt, decryptSessionKey, decrypt with pgp key pair', () => { + it('roundtrip workflow: encrypt, decryptSessionKey, decrypt with pgp key pair', function() { var msgAsciiArmored; return openpgp.encrypt({ data: plaintext, @@ -569,7 +569,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('roundtrip workflow: encrypt, decryptSessionKey, decrypt with password', () => { + it('roundtrip workflow: encrypt, decryptSessionKey, decrypt with password', function() { var msgAsciiArmored; return openpgp.encrypt({ data: plaintext, @@ -610,7 +610,7 @@ describe('OpenPGP.js public api tests', function() { expect(privateKey.keys[0].decrypt(passphrase)).to.be.true; }); - it('should encrypt then decrypt', () => { + it('should encrypt then decrypt', function() { var encOpt = { data: plaintext, publicKeys: publicKey.keys, @@ -629,7 +629,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should encrypt/sign and decrypt/verify', () => { + it('should encrypt/sign and decrypt/verify', function() { var encOpt = { data: plaintext, publicKeys: publicKey.keys, @@ -650,7 +650,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should encrypt/sign and decrypt/verify with detached signatures', () => { + it('should encrypt/sign and decrypt/verify with detached signatures', function() { var encOpt = { data: plaintext, publicKeys: publicKey.keys, @@ -673,7 +673,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should encrypt and decrypt/verify with detached signature input and detached flag set for encryption', () => { + it('should encrypt and decrypt/verify with detached signature input and detached flag set for encryption', function() { var signOpt = { data: plaintext, privateKeys: privateKey.keys[0], @@ -706,7 +706,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should encrypt and decrypt/verify with detached signature as input and detached flag not set for encryption', () => { + it('should encrypt and decrypt/verify with detached signature as input and detached flag not set for encryption', function() { var privKeyDE = openpgp.key.readArmored(priv_key_de).keys[0]; privKeyDE.decrypt(passphrase); @@ -746,7 +746,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should fail to encrypt and decrypt/verify with detached signature input and detached flag set for encryption with wrong public key', () => { + it('should fail to encrypt and decrypt/verify with detached signature input and detached flag set for encryption with wrong public key', function() { var signOpt = { data: plaintext, privateKeys: privateKey.keys, @@ -779,7 +779,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should fail to encrypt and decrypt/verify with detached signature as input and detached flag not set for encryption with wrong public key', () => { + it('should fail to encrypt and decrypt/verify with detached signature as input and detached flag not set for encryption with wrong public key', function() { var signOpt = { data: plaintext, privateKeys: privateKey.keys, @@ -810,7 +810,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should fail to verify decrypted data with wrong public pgp key', () => { + it('should fail to verify decrypted data with wrong public pgp key', function() { var encOpt = { data: plaintext, publicKeys: publicKey.keys, @@ -831,7 +831,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should successfully decrypt signed message without public keys to verify', () => { + it('should successfully decrypt signed message without public keys to verify', function() { var encOpt = { data: plaintext, publicKeys: publicKey.keys, @@ -851,7 +851,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should fail to verify decrypted data with wrong public pgp key with detached signatures', () => { + it('should fail to verify decrypted data with wrong public pgp key with detached signatures', function() { var encOpt = { data: plaintext, publicKeys: publicKey.keys, @@ -874,7 +874,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should sign and verify cleartext data', () => { + it('should sign and verify cleartext data', function() { var signOpt = { data: plaintext, privateKeys: privateKey.keys @@ -894,7 +894,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should sign and verify cleartext data with detached signatures', () => { + it('should sign and verify cleartext data with detached signatures', function() { var signOpt = { data: plaintext, privateKeys: privateKey.keys, @@ -915,7 +915,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should sign and fail to verify cleartext data with wrong public pgp key', () => { + it('should sign and fail to verify cleartext data with wrong public pgp key', function() { var signOpt = { data: plaintext, privateKeys: privateKey.keys @@ -934,7 +934,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should sign and fail to verify cleartext data with wrong public pgp key with detached signature', () => { + it('should sign and fail to verify cleartext data with wrong public pgp key with detached signature', function() { var signOpt = { data: plaintext, privateKeys: privateKey.keys, @@ -955,7 +955,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should sign and verify cleartext data and not armor', () => { + it('should sign and verify cleartext data and not armor', function() { var signOpt = { data: plaintext, privateKeys: privateKey.keys, @@ -975,7 +975,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should sign and verify cleartext data and not armor with detached signatures', () => { + it('should sign and verify cleartext data and not armor with detached signatures', function() { var signOpt = { data: plaintext, privateKeys: privateKey.keys, @@ -999,7 +999,7 @@ describe('OpenPGP.js public api tests', function() { }); describe('ELG / DSA encrypt, decrypt, sign, verify', function() { - it('round trip test', () => { + it('round trip test', function() { var pubKeyDE = openpgp.key.readArmored(pub_key_de).keys[0]; var privKeyDE = openpgp.key.readArmored(priv_key_de).keys[0]; privKeyDE.decrypt(passphrase); @@ -1075,7 +1075,7 @@ describe('OpenPGP.js public api tests', function() { '=IkKW', '-----END PGP PRIVATE KEY BLOCK-----'].join('\n'); - it('Decrypt message', () => { + it('Decrypt message', function() { var privKey, message; privKey = openpgp.key.readArmored(priv_key).keys[0]; @@ -1090,7 +1090,7 @@ describe('OpenPGP.js public api tests', function() { }); describe('AES encrypt, decrypt', function() { - it('should encrypt and decrypt with one password', () => { + it('should encrypt and decrypt with one password', function() { var encOpt = { data: plaintext, passwords: password1 @@ -1107,7 +1107,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should encrypt and decrypt with two passwords', () => { + it('should encrypt and decrypt with two passwords', function() { var encOpt = { data: plaintext, passwords: [password1, password2] @@ -1124,7 +1124,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should encrypt and decrypt with password and not ascii armor', () => { + it('should encrypt and decrypt with password and not ascii armor', function() { var encOpt = { data: plaintext, passwords: password1, @@ -1142,7 +1142,7 @@ describe('OpenPGP.js public api tests', function() { }); }); - it('should encrypt and decrypt with binary data and transferable objects', () => { + it('should encrypt and decrypt with binary data and transferable objects', function() { openpgp.config.zero_copy = true; // activate transferable objects var encOpt = { data: new Uint8Array([0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01]), @@ -1168,7 +1168,7 @@ describe('OpenPGP.js public api tests', function() { describe('Errors', function() { - it('Error message should contain the original error message', () => { + it('Error message should contain the original error message', function() { return openpgp.encrypt({ data: new Uint8Array([0x01, 0x01, 0x01]), passwords: null diff --git a/test/general/packet.js b/test/general/packet.js index 64924421..431e1f3a 100644 --- a/test/general/packet.js +++ b/test/general/packet.js @@ -121,7 +121,7 @@ describe("Packet", function() { done(); }); - it('Sym. encrypted AEAD protected packet', () => { + it('Sym. encrypted AEAD protected packet', function() { var key = new Uint8Array([1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2]), algo = 'aes256'; @@ -170,7 +170,7 @@ describe("Packet", function() { done(); }); - it('Public key encrypted symmetric key packet', () => { + it('Public key encrypted symmetric key packet', function() { var rsa = new openpgp.crypto.publicKey.rsa(); var keySize = openpgp.util.getWebCryptoAll() ? 2048 : 512; // webkit webcrypto accepts minimum 2048 bit keys @@ -430,7 +430,7 @@ describe("Packet", function() { done(); }); - it('Writing and encryption of a secret key packet.', () => { + it('Writing and encryption of a secret key packet.', function() { var key = new openpgp.packet.List(); key.push(new openpgp.packet.SecretKey()); @@ -459,7 +459,7 @@ describe("Packet", function() { }); }); - it('Writing and verification of a signature packet.', () => { + it('Writing and verification of a signature packet.', function() { var key = new openpgp.packet.SecretKey(); var rsa = new openpgp.crypto.publicKey.rsa(); diff --git a/test/general/signature.js b/test/general/signature.js index 97eb3f8d..b1b7ad52 100644 --- a/test/general/signature.js +++ b/test/general/signature.js @@ -257,7 +257,7 @@ describe("Signature", function() { '-----END PGP PUBLIC KEY BLOCK-----' ].join('\n'); - it('Testing signature checking on CAST5-enciphered message', () => { + it('Testing signature checking on CAST5-enciphered message', function() { var priv_key = openpgp.key.readArmored(priv_key_arm1).keys[0]; var pub_key = openpgp.key.readArmored(pub_key_arm1).keys[0]; var msg = openpgp.message.readArmored(msg_arm1); @@ -269,7 +269,7 @@ describe("Signature", function() { }); }); - it('Testing GnuPG stripped-key extensions', () => { + it('Testing GnuPG stripped-key extensions', function() { // exercises the GnuPG s2k type 1001 extension: // the secrets on the primary key have been stripped. var priv_key_gnupg_ext = openpgp.key.readArmored( @@ -361,7 +361,7 @@ describe("Signature", function() { done(); }); - it('Verify signature of signed and encrypted message from GPG2 with openpgp.decrypt', () => { + it('Verify signature of signed and encrypted message from GPG2 with openpgp.decrypt', function() { var msg_armor = [ '-----BEGIN PGP MESSAGE-----', 'Version: GnuPG v2.0.19 (GNU/Linux)', @@ -396,7 +396,7 @@ describe("Signature", function() { }); }); - it('Verify signature of signed and encrypted message from PGP 10.3.0 with openpgp.decrypt', () => { + it('Verify signature of signed and encrypted message from PGP 10.3.0 with openpgp.decrypt', function() { var msg_armor = [ '-----BEGIN PGP MESSAGE-----', 'Version: Encryption Desktop 10.3.0 (Build 9307)', @@ -476,7 +476,7 @@ describe("Signature", function() { done(); }); - it('Verify cleartext signed message with two signatures with openpgp.verify', () => { + it('Verify cleartext signed message with two signatures with openpgp.verify', function() { var msg_armor = [ '-----BEGIN PGP SIGNED MESSAGE-----', 'Hash: SHA256', @@ -522,7 +522,7 @@ describe("Signature", function() { }); }); - it('Sign text with openpgp.sign and verify with openpgp.verify leads to same string cleartext and valid signatures', () => { + it('Sign text with openpgp.sign and verify with openpgp.verify leads to same string cleartext and valid signatures', function() { var plaintext = 'short message\nnext line\n한국어/조선말'; var pubKey = openpgp.key.readArmored(pub_key_arm2).keys[0]; var privKey = openpgp.key.readArmored(priv_key_arm2).keys[0]; @@ -543,7 +543,7 @@ describe("Signature", function() { }); - it('Sign text with openpgp.sign and verify with openpgp.verify leads to same bytes cleartext and valid signatures - armored', () => { + it('Sign text with openpgp.sign and verify with openpgp.verify leads to same bytes cleartext and valid signatures - armored', function() { var plaintext = openpgp.util.str2Uint8Array('short message\nnext line\n한국어/조선말'); var pubKey = openpgp.key.readArmored(pub_key_arm2).keys[0]; var privKey = openpgp.key.readArmored(priv_key_arm2).keys[0]; @@ -563,7 +563,7 @@ describe("Signature", function() { }); - it('Sign text with openpgp.sign and verify with openpgp.verify leads to same bytes cleartext and valid signatures - not armored', () => { + it('Sign text with openpgp.sign and verify with openpgp.verify leads to same bytes cleartext and valid signatures - not armored', function() { var plaintext = openpgp.util.str2Uint8Array('short message\nnext line\n한국어/조선말'); var pubKey = openpgp.key.readArmored(pub_key_arm2).keys[0]; var privKey = openpgp.key.readArmored(priv_key_arm2).keys[0]; @@ -686,7 +686,7 @@ describe("Signature", function() { expect(result[0].valid).to.be.true; }); - it('Detached signature signing and verification', () => { + it('Detached signature signing and verification', function() { var msg = openpgp.message.fromText('hello'); var pubKey2 = openpgp.key.readArmored(pub_key_arm2).keys[0]; var privKey2 = openpgp.key.readArmored(priv_key_arm2).keys[0]; @@ -703,7 +703,7 @@ describe("Signature", function() { }); }); - it('Sign message with key without password', () => { + it('Sign message with key without password', function() { var opt = {numBits: 512, userIds: { name:'test', email:'a@b.com' }, passphrase: null}; if (openpgp.util.getWebCryptoAll()) { opt.numBits = 2048; } // webkit webcrypto accepts minimum 2048 bit keys return openpgp.generateKey(opt).then(function(gen) { diff --git a/test/worker/async_proxy.js b/test/worker/async_proxy.js index d7c2ab7e..8968658d 100644 --- a/test/worker/async_proxy.js +++ b/test/worker/async_proxy.js @@ -49,7 +49,7 @@ tryTests('Async Proxy', tests, { function tests() { describe('Error handling', function() { - it('Depleted random buffer in worker gives error', () => { + it('Depleted random buffer in worker gives error', function() { var wProxy = new openpgp.AsyncProxy({ path:'../dist/openpgp.worker.js' }); wProxy.worker = new Worker('../dist/openpgp.worker.js'); wProxy.worker.onmessage = wProxy.onMessage.bind(wProxy);