0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00

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 <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Rich Trott 2019-01-28 02:21:04 -08:00
parent 5e1d4462d2
commit 86a49ce2d8
2 changed files with 15 additions and 15 deletions

View File

@ -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;
});

View File

@ -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);
});