From 86a49ce2d8870e37089e3450addb05737ae01d70 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 28 Jan 2019 02:21:04 -0800 Subject: [PATCH] test: move client renegotiation tests to parallel * Move client renegotiation limit tests from pummel to parallel. * Rename tests to more accurately reflect what they do. * Refactor to use arrow functions for anonymouse callbacks and to be consistent about trailing commas. PR-URL: https://github.com/nodejs/node/pull/25757 Reviewed-By: Beth Griggs Reviewed-By: Sam Roberts Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- .../test-https-client-renegotiation-limit.js} | 14 +++++++------- .../test-tls-client-renegotiation-limit.js} | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) rename test/{pummel/test-https-ci-reneg-attack.js => parallel/test-https-client-renegotiation-limit.js} (91%) rename test/{pummel/test-tls-ci-reneg-attack.js => parallel/test-tls-client-renegotiation-limit.js} (88%) diff --git a/test/pummel/test-https-ci-reneg-attack.js b/test/parallel/test-https-client-renegotiation-limit.js similarity index 91% rename from test/pummel/test-https-ci-reneg-attack.js rename to test/parallel/test-https-client-renegotiation-limit.js index 592dd6827320a1..1fccc7bb5d1629 100644 --- a/test/pummel/test-https-ci-reneg-attack.js +++ b/test/parallel/test-https-client-renegotiation-limit.js @@ -48,12 +48,12 @@ const LIMITS = [0, 1, 2, 3, 5, 10, 16]; function test(next) { const options = { cert: fixtures.readSync('test_cert.pem'), - key: fixtures.readSync('test_key.pem') + key: fixtures.readSync('test_key.pem'), }; - const server = https.createServer(options, function(req, res) { + const server = https.createServer(options, (req, res) => { const conn = req.connection; - conn.on('error', function(err) { + conn.on('error', (err) => { console.error(`Caught exception: ${err}`); assert(/TLS session renegotiation attack/.test(err)); conn.destroy(); @@ -61,7 +61,7 @@ function test(next) { res.end('ok'); }); - server.listen(0, function() { + server.listen(0, () => { const agent = https.Agent({ keepAlive: true, }); @@ -71,7 +71,7 @@ function test(next) { const options = { rejectUnauthorized: false, - agent + agent, }; const { port } = server.address(); @@ -79,14 +79,14 @@ function test(next) { https.get(`https://localhost:${port}/`, options, (res) => { client = res.socket; - client.on('close', function(hadErr) { + client.on('close', (hadErr) => { assert.strictEqual(hadErr, false); assert.strictEqual(renegs, tls.CLIENT_RENEG_LIMIT + 1); server.close(); process.nextTick(next); }); - client.on('error', function(err) { + client.on('error', (err) => { console.log('CLIENT ERR', err); throw err; }); diff --git a/test/pummel/test-tls-ci-reneg-attack.js b/test/parallel/test-tls-client-renegotiation-limit.js similarity index 88% rename from test/pummel/test-tls-ci-reneg-attack.js rename to test/parallel/test-tls-client-renegotiation-limit.js index 558efdbdece9e5..daae92eeb46d67 100644 --- a/test/pummel/test-tls-ci-reneg-attack.js +++ b/test/parallel/test-tls-client-renegotiation-limit.js @@ -47,11 +47,11 @@ const LIMITS = [0, 1, 2, 3, 5, 10, 16]; function test(next) { const options = { cert: fixtures.readSync('test_cert.pem'), - key: fixtures.readSync('test_key.pem') + key: fixtures.readSync('test_key.pem'), }; - const server = tls.createServer(options, function(conn) { - conn.on('error', function(err) { + const server = tls.createServer(options, (conn) => { + conn.on('error', (err) => { console.error(`Caught exception: ${err}`); assert(/TLS session renegotiation attack/.test(err)); conn.destroy(); @@ -59,28 +59,28 @@ function test(next) { conn.pipe(conn); }); - server.listen(0, function() { + server.listen(0, () => { const options = { host: server.address().host, port: server.address().port, - rejectUnauthorized: false + rejectUnauthorized: false, }; const client = tls.connect(options, spam); let renegs = 0; - client.on('close', function() { + client.on('close', () => { assert.strictEqual(renegs, tls.CLIENT_RENEG_LIMIT + 1); server.close(); process.nextTick(next); }); - client.on('error', function(err) { + client.on('error', (err) => { console.log('CLIENT ERR', err); throw err; }); - client.on('close', function(hadErr) { + client.on('close', (hadErr) => { assert.strictEqual(hadErr, false); });