Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions test/parallel/test-https-agent-session-reuse.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
'use strict';
var common = require('../common');
var assert = require('assert');
const common = require('../common');
const assert = require('assert');

if (!common.hasCrypto) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move the const assert = require('assert'); after the if (!common.hasCrypto) {.

common.skip('missing crypto');
return;
}

var https = require('https');
var crypto = require('crypto');
const https = require('https');
const crypto = require('crypto');

var fs = require('fs');
const fs = require('fs');

var options = {
const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};

var ca = fs.readFileSync(common.fixturesDir + '/keys/ca1-cert.pem');
const ca = fs.readFileSync(common.fixturesDir + '/keys/ca1-cert.pem');

var clientSessions = {};
var serverRequests = 0;
const clientSessions = {};
let serverRequests = 0;

var agent = new https.Agent({
const agent = new https.Agent({
maxCachedSessions: 1
});

var server = https.createServer(options, function(req, res) {
const server = https.createServer(options, function(req, res) {
if (req.url === '/drop-key')
server.setTicketKeys(crypto.randomBytes(48));

serverRequests++;
res.end('ok');
}).listen(0, function() {
var queue = [
const queue = [
{
name: 'first',

Expand Down Expand Up @@ -97,7 +97,7 @@ var server = https.createServer(options, function(req, res) {
];

function request() {
var options = queue.shift();
const options = queue.shift();
options.agent = agent;
https.request(options, function(res) {
clientSessions[options.name] = res.socket.getSession();
Expand All @@ -114,9 +114,9 @@ var server = https.createServer(options, function(req, res) {
});

process.on('exit', function() {
assert.equal(serverRequests, 6);
assert.equal(clientSessions['first'].toString('hex'),
clientSessions['first-reuse'].toString('hex'));
assert.strictEqual(serverRequests, 6);
assert.strictEqual(clientSessions['first'].toString('hex'),
clientSessions['first-reuse'].toString('hex'));
assert.notEqual(clientSessions['first'].toString('hex'),
clientSessions['cipher-change'].toString('hex'));
assert.notEqual(clientSessions['first'].toString('hex'),
Expand All @@ -125,6 +125,6 @@ process.on('exit', function() {
clientSessions['before-drop'].toString('hex'));
assert.notEqual(clientSessions['before-drop'].toString('hex'),
clientSessions['after-drop'].toString('hex'));
assert.equal(clientSessions['after-drop'].toString('hex'),
clientSessions['after-drop-reuse'].toString('hex'));
assert.strictEqual(clientSessions['after-drop'].toString('hex'),
clientSessions['after-drop-reuse'].toString('hex'));
});