Skip to content

Commit ffd64ad

Browse files
kathytruongjasnell
authored andcommitted
test: refactor test-tls-ocsp-callback
refactor all var to either const/let change all assert.equal to assert.strictEqual change all assert.ok(...===...) to assert.strictEqual PR-URL: #9970 Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent f7a35df commit ffd64ad

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

test/parallel/test-tls-ocsp-callback.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
var common = require('../common');
2+
const common = require('../common');
33

44
if (!process.features.tls_ocsp) {
55
common.skip('node compiled without OpenSSL or ' +
@@ -15,33 +15,33 @@ if (!common.hasCrypto) {
1515
common.skip('missing crypto');
1616
return;
1717
}
18-
var tls = require('tls');
18+
const tls = require('tls');
1919

20-
var assert = require('assert');
21-
var fs = require('fs');
22-
var join = require('path').join;
20+
const assert = require('assert');
21+
const fs = require('fs');
22+
const join = require('path').join;
2323

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

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

2828
function test(testOptions, cb) {
2929

30-
var keyFile = join(common.fixturesDir, 'keys', 'agent1-key.pem');
31-
var certFile = join(common.fixturesDir, 'keys', 'agent1-cert.pem');
32-
var caFile = join(common.fixturesDir, 'keys', 'ca1-cert.pem');
33-
var key = fs.readFileSync(keyFile);
34-
var cert = fs.readFileSync(certFile);
35-
var ca = fs.readFileSync(caFile);
36-
var options = {
30+
const keyFile = join(common.fixturesDir, 'keys', 'agent1-key.pem');
31+
const certFile = join(common.fixturesDir, 'keys', 'agent1-cert.pem');
32+
const caFile = join(common.fixturesDir, 'keys', 'ca1-cert.pem');
33+
const key = fs.readFileSync(keyFile);
34+
const cert = fs.readFileSync(certFile);
35+
const ca = fs.readFileSync(caFile);
36+
const options = {
3737
key: key,
3838
cert: cert,
3939
ca: [ca]
4040
};
41-
var requestCount = 0;
42-
var clientSecure = 0;
43-
var ocspCount = 0;
44-
var ocspResponse;
41+
let requestCount = 0;
42+
let clientSecure = 0;
43+
let ocspCount = 0;
44+
let ocspResponse;
4545

4646
if (testOptions.pfx) {
4747
delete options.key;
@@ -50,7 +50,7 @@ function test(testOptions, cb) {
5050
options.passphrase = testOptions.passphrase;
5151
}
5252

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

9595
process.on('exit', function() {
9696
if (testOptions.ocsp === false) {
97-
assert.equal(requestCount, clientSecure);
98-
assert.equal(requestCount, 1);
97+
assert.strictEqual(requestCount, clientSecure);
98+
assert.strictEqual(requestCount, 1);
9999
return;
100100
}
101101

102102
if (testOptions.response) {
103-
assert.equal(ocspResponse.toString(), testOptions.response);
103+
assert.strictEqual(ocspResponse.toString(), testOptions.response);
104104
} else {
105-
assert.ok(ocspResponse === null);
105+
assert.strictEqual(ocspResponse, null);
106106
}
107-
assert.equal(requestCount, testOptions.response ? 0 : 1);
108-
assert.equal(clientSecure, requestCount);
109-
assert.equal(ocspCount, 1);
107+
assert.strictEqual(requestCount, testOptions.response ? 0 : 1);
108+
assert.strictEqual(clientSecure, requestCount);
109+
assert.strictEqual(ocspCount, 1);
110110
});
111111
}
112112

113-
var tests = [
113+
const tests = [
114114
{ response: false },
115115
{ response: 'hello world' },
116116
{ ocsp: false }

0 commit comments

Comments
 (0)