Skip to content

Commit

Permalink
test: refactor test-tls-ocsp-callback
Browse files Browse the repository at this point in the history
refactor all var to either const/let
change all assert.equal to assert.strictEqual
change all assert.ok(...===...) to assert.strictEqual

PR-URL: nodejs#9970
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
kathytruong authored and Jonathan Darling committed Dec 8, 2016
1 parent 35093eb commit 85850af
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions test/parallel/test-tls-ocsp-callback.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
var common = require('../common');
const common = require('../common');

if (!process.features.tls_ocsp) {
common.skip('node compiled without OpenSSL or ' +
Expand All @@ -15,33 +15,33 @@ if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
var tls = require('tls');
const tls = require('tls');

var assert = require('assert');
var fs = require('fs');
var join = require('path').join;
const assert = require('assert');
const fs = require('fs');
const join = require('path').join;

const SSL_OP_NO_TICKET = require('crypto').constants.SSL_OP_NO_TICKET;

var pfx = fs.readFileSync(join(common.fixturesDir, 'keys', 'agent1-pfx.pem'));
const pfx = fs.readFileSync(join(common.fixturesDir, 'keys', 'agent1-pfx.pem'));

function test(testOptions, cb) {

var keyFile = join(common.fixturesDir, 'keys', 'agent1-key.pem');
var certFile = join(common.fixturesDir, 'keys', 'agent1-cert.pem');
var caFile = join(common.fixturesDir, 'keys', 'ca1-cert.pem');
var key = fs.readFileSync(keyFile);
var cert = fs.readFileSync(certFile);
var ca = fs.readFileSync(caFile);
var options = {
const keyFile = join(common.fixturesDir, 'keys', 'agent1-key.pem');
const certFile = join(common.fixturesDir, 'keys', 'agent1-cert.pem');
const caFile = join(common.fixturesDir, 'keys', 'ca1-cert.pem');
const key = fs.readFileSync(keyFile);
const cert = fs.readFileSync(certFile);
const ca = fs.readFileSync(caFile);
const options = {
key: key,
cert: cert,
ca: [ca]
};
var requestCount = 0;
var clientSecure = 0;
var ocspCount = 0;
var ocspResponse;
let requestCount = 0;
let clientSecure = 0;
let ocspCount = 0;
let ocspResponse;

if (testOptions.pfx) {
delete options.key;
Expand All @@ -50,7 +50,7 @@ function test(testOptions, cb) {
options.passphrase = testOptions.passphrase;
}

var server = tls.createServer(options, function(cleartext) {
const server = tls.createServer(options, function(cleartext) {
cleartext.on('error', function(er) {
// We're ok with getting ECONNRESET in this test, but it's
// timing-dependent, and thus unreliable. Any other errors
Expand All @@ -73,7 +73,7 @@ function test(testOptions, cb) {
}, 100);
});
server.listen(0, function() {
var client = tls.connect({
const client = tls.connect({
port: this.address().port,
requestOCSP: testOptions.ocsp !== false,
secureOptions: testOptions.ocsp === false ?
Expand All @@ -94,23 +94,23 @@ function test(testOptions, cb) {

process.on('exit', function() {
if (testOptions.ocsp === false) {
assert.equal(requestCount, clientSecure);
assert.equal(requestCount, 1);
assert.strictEqual(requestCount, clientSecure);
assert.strictEqual(requestCount, 1);
return;
}

if (testOptions.response) {
assert.equal(ocspResponse.toString(), testOptions.response);
assert.strictEqual(ocspResponse.toString(), testOptions.response);
} else {
assert.ok(ocspResponse === null);
assert.strictEqual(ocspResponse, null);
}
assert.equal(requestCount, testOptions.response ? 0 : 1);
assert.equal(clientSecure, requestCount);
assert.equal(ocspCount, 1);
assert.strictEqual(requestCount, testOptions.response ? 0 : 1);
assert.strictEqual(clientSecure, requestCount);
assert.strictEqual(ocspCount, 1);
});
}

var tests = [
const tests = [
{ response: false },
{ response: 'hello world' },
{ ocsp: false }
Expand Down

0 comments on commit 85850af

Please sign in to comment.