Skip to content

Commit

Permalink
test: move client renegotiation tests to parallel
Browse files Browse the repository at this point in the history
* 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: #25757
Reviewed-By: Beth Griggs <[email protected]>
Reviewed-By: Sam Roberts <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Trott committed Jan 30, 2019
1 parent 5e1d446 commit 86a49ce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ 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();
});
res.end('ok');
});

server.listen(0, function() {
server.listen(0, () => {
const agent = https.Agent({
keepAlive: true,
});
Expand All @@ -71,22 +71,22 @@ function test(next) {

const options = {
rejectUnauthorized: false,
agent
agent,
};

const { port } = server.address();

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;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,40 +47,40 @@ 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();
});
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);
});

Expand Down

0 comments on commit 86a49ce

Please sign in to comment.