| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 19907c2 commit 812c636
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 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,12 +102,12 @@ 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 | - 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; | ||
| 111 | 111 | ||
| 112 | 112 | ||
| 113 | 113 | function filenamePEM(n) { | |
@@ -120,8 +120,8 @@ function loadPEM(n) { | |||
| 120 | 120 | } | |
| 121 | 121 | ||
| 122 | 122 | ||
| 123 | - var serverKey = loadPEM('agent2-key'); | ||
| 124 | - var serverCert = loadPEM('agent2-cert'); | ||
| 123 | + const serverKey = loadPEM('agent2-key'); | ||
| 124 | + const serverCert = loadPEM('agent2-cert'); | ||
| 125 | 125 | ||
| 126 | 126 | ||
| 127 | 127 | function runClient(prefix, port, options, cb) { | |
@@ -131,7 +131,7 @@ function runClient(prefix, port, options, cb) { | |||
| 131 | 131 | // - Certificate, but not signed by CA. | |
| 132 | 132 | // - Certificate signed by CA. | |
| 133 | 133 | ||
| 134 | - var args = ['s_client', '-connect', '127.0.0.1:' + port]; | ||
| 134 | + const args = ['s_client', '-connect', '127.0.0.1:' + port]; | ||
| 135 | 135 | ||
| 136 | 136 | // for the performance issue in s_client on Windows | |
| 137 | 137 | if (common.isWindows) | |
@@ -182,13 +182,13 @@ function runClient(prefix, port, options, cb) { | |||
| 182 | 182 | } | |
| 183 | 183 | ||
| 184 | 184 | // To test use: openssl s_client -connect localhost:8000 | |
| 185 | - var client = spawn(common.opensslCli, args); | ||
| 185 | + const client = spawn(common.opensslCli, args); | ||
| 186 | 186 | ||
| 187 | - var out = ''; | ||
| 187 | + let out = ''; | ||
| 188 | 188 | ||
| 189 | - var rejected = true; | ||
| 190 | - var authed = false; | ||
| 191 | - var goodbye = false; | ||
| 189 | + let rejected = true; | ||
| 190 | + let authed = false; | ||
| 191 | + let goodbye = false; | ||
| 192 | 192 | ||
| 193 | 193 | client.stdout.setEncoding('utf8'); | |
| 194 | 194 | client.stdout.on('data', function(d) { | |
@@ -217,12 +217,12 @@ function runClient(prefix, port, options, cb) { | |||
| 217 | 217 | //assert.equal(0, code, prefix + options.name + | |
| 218 | 218 | // ": s_client exited with error code " + code); | |
| 219 | 219 | if (options.shouldReject) { | |
| 220 | - assert.equal(true, rejected, prefix + options.name + | ||
| 220 | + assert.strictEqual(true, rejected, prefix + options.name + | ||
| 221 | 221 | ' NOT rejected, but should have been'); | |
| 222 | 222 | } else { | |
| 223 | - assert.equal(false, rejected, prefix + options.name + | ||
| 223 | + assert.strictEqual(false, rejected, prefix + options.name + | ||
| 224 | 224 | ' rejected, but should NOT have been'); | |
| 225 | - assert.equal(options.shouldAuth, authed, prefix + | ||
| 225 | + assert.strictEqual(options.shouldAuth, authed, prefix + | ||
| 226 | 226 | options.name + ' authed is ' + authed + | |
| 227 | 227 | ' but should have been ' + options.shouldAuth); | |
| 228 | 228 | } | |
@@ -233,19 +233,19 @@ function runClient(prefix, port, options, cb) { | |||
| 233 | 233 | ||
| 234 | 234 | ||
| 235 | 235 | // Run the tests | |
| 236 | - var successfulTests = 0; | ||
| 236 | + let successfulTests = 0; | ||
| 237 | 237 | function runTest(port, testIndex) { | |
| 238 | - var prefix = testIndex + ' '; | ||
| 239 | - var tcase = testCases[testIndex]; | ||
| 238 | + const prefix = testIndex + ' '; | ||
| 239 | + const tcase = testCases[testIndex]; | ||
| 240 | 240 | if (!tcase) return; | |
| 241 | 241 | ||
| 242 | 242 | console.error(prefix + "Running '%s'", tcase.title); | |
| 243 | 243 | ||
| 244 | - var cas = tcase.CAs.map(loadPEM); | ||
| 244 | + const cas = tcase.CAs.map(loadPEM); | ||
| 245 | 245 | ||
| 246 | - var crl = tcase.crl ? loadPEM(tcase.crl) : null; | ||
| 246 | + const crl = tcase.crl ? loadPEM(tcase.crl) : null; | ||
| 247 | 247 | ||
| 248 | - var serverOptions = { | ||
| 248 | + const serverOptions = { | ||
| 249 | 249 | key: serverKey, | |
| 250 | 250 | cert: serverCert, | |
| 251 | 251 | ca: cas, | |
@@ -263,8 +263,8 @@ function runTest(port, testIndex) { | |||
| 263 | 263 | constants.SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION; | |
| 264 | 264 | } | |
| 265 | 265 | ||
| 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) { | ||
| 268 | 268 | c.on('error', function(e) { | |
| 269 | 269 | // child.kill() leads ECONNRESET errro in the TLS connection of | |
| 270 | 270 | // openssl s_client via spawn(). A Test result is already | |
@@ -299,7 +299,7 @@ function runTest(port, testIndex) { | |||
| 299 | 299 | }); | |
| 300 | 300 | ||
| 301 | 301 | function runNextClient(clientIndex) { | |
| 302 | - var options = tcase.clients[clientIndex]; | ||
| 302 | + const options = tcase.clients[clientIndex]; | ||
| 303 | 303 | if (options) { | |
| 304 | 304 | runClient(prefix + clientIndex + ' ', port, options, function() { | |
| 305 | 305 | runNextClient(clientIndex + 1); | |
@@ -319,8 +319,8 @@ function runTest(port, testIndex) { | |||
| 319 | 319 | if (tcase.renegotiate) { | |
| 320 | 320 | runNextClient(0); | |
| 321 | 321 | } 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++) { | ||
| 324 | 324 | runClient(prefix + i + ' ', port, tcase.clients[i], function() { | |
| 325 | 325 | clientsCompleted++; | |
| 326 | 326 | if (clientsCompleted === tcase.clients.length) { | |
@@ -336,11 +336,11 @@ function runTest(port, testIndex) { | |||
| 336 | 336 | } | |
| 337 | 337 | ||
| 338 | 338 | ||
| 339 | - var nextTest = 0; | ||
| 339 | + let nextTest = 0; | ||
| 340 | 340 | runTest(0, nextTest++); | |
| 341 | 341 | runTest(0, nextTest++); | |
| 342 | 342 | ||
| 343 | 343 | ||
| 344 | 344 | process.on('exit', function() { | |
| 345 | - assert.equal(successfulTests, testCases.length); | ||
| 345 | + assert.strictEqual(successfulTests, testCases.length); | ||
| 346 | 346 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments