1
1
'use strict' ;
2
- var common = require ( '../common' ) ;
2
+ const common = require ( '../common' ) ;
3
3
4
4
if ( ! common . opensslCli ) {
5
5
common . skip ( 'node compiled without OpenSSL CLI.' ) ;
@@ -14,7 +14,7 @@ if (!common.opensslCli) {
14
14
// - accepted and "unauthorized", or
15
15
// - accepted and "authorized".
16
16
17
- var testCases =
17
+ const testCases =
18
18
[ { title : 'Do not request certs. Everyone is unauthorized.' ,
19
19
requestCert : false ,
20
20
rejectUnauthorized : false ,
@@ -102,14 +102,14 @@ if (!common.hasCrypto) {
102
102
common . skip ( 'missing crypto' ) ;
103
103
return ;
104
104
}
105
- var tls = require ( 'tls' ) ;
105
+ const tls = require ( 'tls' ) ;
106
106
107
107
const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION =
108
108
require ( 'crypto' ) . constants . SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION ;
109
109
110
- var assert = require ( 'assert' ) ;
111
- var fs = require ( 'fs' ) ;
112
- var spawn = require ( 'child_process' ) . spawn ;
110
+ const assert = require ( 'assert' ) ;
111
+ const fs = require ( 'fs' ) ;
112
+ const spawn = require ( 'child_process' ) . spawn ;
113
113
114
114
115
115
function filenamePEM ( n ) {
@@ -122,8 +122,8 @@ function loadPEM(n) {
122
122
}
123
123
124
124
125
- var serverKey = loadPEM ( 'agent2-key' ) ;
126
- var serverCert = loadPEM ( 'agent2-cert' ) ;
125
+ const serverKey = loadPEM ( 'agent2-key' ) ;
126
+ const serverCert = loadPEM ( 'agent2-cert' ) ;
127
127
128
128
129
129
function runClient ( prefix , port , options , cb ) {
@@ -133,7 +133,7 @@ function runClient(prefix, port, options, cb) {
133
133
// - Certificate, but not signed by CA.
134
134
// - Certificate signed by CA.
135
135
136
- var args = [ 's_client' , '-connect' , '127.0.0.1:' + port ] ;
136
+ const args = [ 's_client' , '-connect' , '127.0.0.1:' + port ] ;
137
137
138
138
// for the performance issue in s_client on Windows
139
139
if ( common . isWindows )
@@ -184,13 +184,13 @@ function runClient(prefix, port, options, cb) {
184
184
}
185
185
186
186
// To test use: openssl s_client -connect localhost:8000
187
- var client = spawn ( common . opensslCli , args ) ;
187
+ const client = spawn ( common . opensslCli , args ) ;
188
188
189
- var out = '' ;
189
+ let out = '' ;
190
190
191
- var rejected = true ;
192
- var authed = false ;
193
- var goodbye = false ;
191
+ let rejected = true ;
192
+ let authed = false ;
193
+ let goodbye = false ;
194
194
195
195
client . stdout . setEncoding ( 'utf8' ) ;
196
196
client . stdout . on ( 'data' , function ( d ) {
@@ -219,12 +219,12 @@ function runClient(prefix, port, options, cb) {
219
219
//assert.equal(0, code, prefix + options.name +
220
220
// ": s_client exited with error code " + code);
221
221
if ( options . shouldReject ) {
222
- assert . equal ( true , rejected , prefix + options . name +
222
+ assert . strictEqual ( true , rejected , prefix + options . name +
223
223
' NOT rejected, but should have been' ) ;
224
224
} else {
225
- assert . equal ( false , rejected , prefix + options . name +
225
+ assert . strictEqual ( false , rejected , prefix + options . name +
226
226
' rejected, but should NOT have been' ) ;
227
- assert . equal ( options . shouldAuth , authed , prefix +
227
+ assert . strictEqual ( options . shouldAuth , authed , prefix +
228
228
options . name + ' authed is ' + authed +
229
229
' but should have been ' + options . shouldAuth ) ;
230
230
}
@@ -235,19 +235,19 @@ function runClient(prefix, port, options, cb) {
235
235
236
236
237
237
// Run the tests
238
- var successfulTests = 0 ;
238
+ let successfulTests = 0 ;
239
239
function runTest ( port , testIndex ) {
240
- var prefix = testIndex + ' ' ;
241
- var tcase = testCases [ testIndex ] ;
240
+ const prefix = testIndex + ' ' ;
241
+ const tcase = testCases [ testIndex ] ;
242
242
if ( ! tcase ) return ;
243
243
244
244
console . error ( prefix + "Running '%s'" , tcase . title ) ;
245
245
246
- var cas = tcase . CAs . map ( loadPEM ) ;
246
+ const cas = tcase . CAs . map ( loadPEM ) ;
247
247
248
- var crl = tcase . crl ? loadPEM ( tcase . crl ) : null ;
248
+ const crl = tcase . crl ? loadPEM ( tcase . crl ) : null ;
249
249
250
- var serverOptions = {
250
+ const serverOptions = {
251
251
key : serverKey ,
252
252
cert : serverCert ,
253
253
ca : cas ,
@@ -265,8 +265,8 @@ function runTest(port, testIndex) {
265
265
SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION ;
266
266
}
267
267
268
- var renegotiated = false ;
269
- var server = tls . Server ( serverOptions , function handleConnection ( c ) {
268
+ let renegotiated = false ;
269
+ const server = tls . Server ( serverOptions , function handleConnection ( c ) {
270
270
c . on ( 'error' , function ( e ) {
271
271
// child.kill() leads ECONNRESET errro in the TLS connection of
272
272
// openssl s_client via spawn(). A Test result is already
@@ -301,7 +301,7 @@ function runTest(port, testIndex) {
301
301
} ) ;
302
302
303
303
function runNextClient ( clientIndex ) {
304
- var options = tcase . clients [ clientIndex ] ;
304
+ const options = tcase . clients [ clientIndex ] ;
305
305
if ( options ) {
306
306
runClient ( prefix + clientIndex + ' ' , port , options , function ( ) {
307
307
runNextClient ( clientIndex + 1 ) ;
@@ -321,8 +321,8 @@ function runTest(port, testIndex) {
321
321
if ( tcase . renegotiate ) {
322
322
runNextClient ( 0 ) ;
323
323
} else {
324
- var clientsCompleted = 0 ;
325
- for ( var i = 0 ; i < tcase . clients . length ; i ++ ) {
324
+ let clientsCompleted = 0 ;
325
+ for ( let i = 0 ; i < tcase . clients . length ; i ++ ) {
326
326
runClient ( prefix + i + ' ' , port , tcase . clients [ i ] , function ( ) {
327
327
clientsCompleted ++ ;
328
328
if ( clientsCompleted === tcase . clients . length ) {
@@ -338,11 +338,11 @@ function runTest(port, testIndex) {
338
338
}
339
339
340
340
341
- var nextTest = 0 ;
341
+ let nextTest = 0 ;
342
342
runTest ( 0 , nextTest ++ ) ;
343
343
runTest ( 0 , nextTest ++ ) ;
344
344
345
345
346
346
process . on ( 'exit' , function ( ) {
347
- assert . equal ( successfulTests , testCases . length ) ;
347
+ assert . strictEqual ( successfulTests , testCases . length ) ;
348
348
} ) ;
0 commit comments