Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 812c636

Browse filesBrowse files
Hutson BettsMylesBorins
authored andcommitted
test: refactor test-tls-server-verify
Refactored `test-tls-server-verify.js` to replace uses of `var` with `const` and `let`. Also replaced uses of `assert.equal` with `assert.strictEqual`. PR-URL: #10076 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 19907c2 commit 812c636
Copy full SHA for 812c636

File tree

Expand file treeCollapse file tree

1 file changed

+31
-31
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+31
-31
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-tls-server-verify.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-tls-server-verify.js
+31-31Lines changed: 31 additions & 31 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 (!common.opensslCli) {
55
common.skip('node compiled without OpenSSL CLI.');
@@ -14,7 +14,7 @@ if (!common.opensslCli) {
1414
// - accepted and "unauthorized", or
1515
// - accepted and "authorized".
1616

17-
var testCases =
17+
const testCases =
1818
[{ title: 'Do not request certs. Everyone is unauthorized.',
1919
requestCert: false,
2020
rejectUnauthorized: false,
@@ -102,12 +102,12 @@ if (!common.hasCrypto) {
102102
common.skip('missing crypto');
103103
return;
104104
}
105-
var tls = require('tls');
105+
const tls = require('tls');
106106

107-
var constants = require('constants');
108-
var assert = require('assert');
109-
var fs = require('fs');
110-
var spawn = require('child_process').spawn;
107+
const constants = require('constants');
108+
const assert = require('assert');
109+
const fs = require('fs');
110+
const spawn = require('child_process').spawn;
111111

112112

113113
function filenamePEM(n) {
@@ -120,8 +120,8 @@ function loadPEM(n) {
120120
}
121121

122122

123-
var serverKey = loadPEM('agent2-key');
124-
var serverCert = loadPEM('agent2-cert');
123+
const serverKey = loadPEM('agent2-key');
124+
const serverCert = loadPEM('agent2-cert');
125125

126126

127127
function runClient(prefix, port, options, cb) {
@@ -131,7 +131,7 @@ function runClient(prefix, port, options, cb) {
131131
// - Certificate, but not signed by CA.
132132
// - Certificate signed by CA.
133133

134-
var args = ['s_client', '-connect', '127.0.0.1:' + port];
134+
const args = ['s_client', '-connect', '127.0.0.1:' + port];
135135

136136
// for the performance issue in s_client on Windows
137137
if (common.isWindows)
@@ -182,13 +182,13 @@ function runClient(prefix, port, options, cb) {
182182
}
183183

184184
// To test use: openssl s_client -connect localhost:8000
185-
var client = spawn(common.opensslCli, args);
185+
const client = spawn(common.opensslCli, args);
186186

187-
var out = '';
187+
let out = '';
188188

189-
var rejected = true;
190-
var authed = false;
191-
var goodbye = false;
189+
let rejected = true;
190+
let authed = false;
191+
let goodbye = false;
192192

193193
client.stdout.setEncoding('utf8');
194194
client.stdout.on('data', function(d) {
@@ -217,12 +217,12 @@ function runClient(prefix, port, options, cb) {
217217
//assert.equal(0, code, prefix + options.name +
218218
// ": s_client exited with error code " + code);
219219
if (options.shouldReject) {
220-
assert.equal(true, rejected, prefix + options.name +
220+
assert.strictEqual(true, rejected, prefix + options.name +
221221
' NOT rejected, but should have been');
222222
} else {
223-
assert.equal(false, rejected, prefix + options.name +
223+
assert.strictEqual(false, rejected, prefix + options.name +
224224
' rejected, but should NOT have been');
225-
assert.equal(options.shouldAuth, authed, prefix +
225+
assert.strictEqual(options.shouldAuth, authed, prefix +
226226
options.name + ' authed is ' + authed +
227227
' but should have been ' + options.shouldAuth);
228228
}
@@ -233,19 +233,19 @@ function runClient(prefix, port, options, cb) {
233233

234234

235235
// Run the tests
236-
var successfulTests = 0;
236+
let successfulTests = 0;
237237
function runTest(port, testIndex) {
238-
var prefix = testIndex + ' ';
239-
var tcase = testCases[testIndex];
238+
const prefix = testIndex + ' ';
239+
const tcase = testCases[testIndex];
240240
if (!tcase) return;
241241

242242
console.error(prefix + "Running '%s'", tcase.title);
243243

244-
var cas = tcase.CAs.map(loadPEM);
244+
const cas = tcase.CAs.map(loadPEM);
245245

246-
var crl = tcase.crl ? loadPEM(tcase.crl) : null;
246+
const crl = tcase.crl ? loadPEM(tcase.crl) : null;
247247

248-
var serverOptions = {
248+
const serverOptions = {
249249
key: serverKey,
250250
cert: serverCert,
251251
ca: cas,
@@ -263,8 +263,8 @@ function runTest(port, testIndex) {
263263
constants.SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION;
264264
}
265265

266-
var renegotiated = false;
267-
var server = tls.Server(serverOptions, function handleConnection(c) {
266+
let renegotiated = false;
267+
const server = tls.Server(serverOptions, function handleConnection(c) {
268268
c.on('error', function(e) {
269269
// child.kill() leads ECONNRESET errro in the TLS connection of
270270
// openssl s_client via spawn(). A Test result is already
@@ -299,7 +299,7 @@ function runTest(port, testIndex) {
299299
});
300300

301301
function runNextClient(clientIndex) {
302-
var options = tcase.clients[clientIndex];
302+
const options = tcase.clients[clientIndex];
303303
if (options) {
304304
runClient(prefix + clientIndex + ' ', port, options, function() {
305305
runNextClient(clientIndex + 1);
@@ -319,8 +319,8 @@ function runTest(port, testIndex) {
319319
if (tcase.renegotiate) {
320320
runNextClient(0);
321321
} else {
322-
var clientsCompleted = 0;
323-
for (var i = 0; i < tcase.clients.length; i++) {
322+
let clientsCompleted = 0;
323+
for (let i = 0; i < tcase.clients.length; i++) {
324324
runClient(prefix + i + ' ', port, tcase.clients[i], function() {
325325
clientsCompleted++;
326326
if (clientsCompleted === tcase.clients.length) {
@@ -336,11 +336,11 @@ function runTest(port, testIndex) {
336336
}
337337

338338

339-
var nextTest = 0;
339+
let nextTest = 0;
340340
runTest(0, nextTest++);
341341
runTest(0, nextTest++);
342342

343343

344344
process.on('exit', function() {
345-
assert.equal(successfulTests, testCases.length);
345+
assert.strictEqual(successfulTests, testCases.length);
346346
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.