diff options
author | k3kathy <kathy.yvy.truong@gmail.com> | 2016-12-01 10:16:42 -0600 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-12-06 07:31:20 -0800 |
commit | ffd64adc7827c4df594620007c27fc76fc6d10c9 (patch) | |
tree | cbe52cc0c82c978f29081b5b3465970073a8e7f6 /test/parallel/test-tls-ocsp-callback.js | |
parent | f7a35df171f16a6e79de3343ccbebb0dd8df124e (diff) | |
download | android-node-v8-ffd64adc7827c4df594620007c27fc76fc6d10c9.tar.gz android-node-v8-ffd64adc7827c4df594620007c27fc76fc6d10c9.tar.bz2 android-node-v8-ffd64adc7827c4df594620007c27fc76fc6d10c9.zip |
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: https://github.com/nodejs/node/pull/9970
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-tls-ocsp-callback.js')
-rw-r--r-- | test/parallel/test-tls-ocsp-callback.js | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/test/parallel/test-tls-ocsp-callback.js b/test/parallel/test-tls-ocsp-callback.js index 442f54791a..c008613c2c 100644 --- a/test/parallel/test-tls-ocsp-callback.js +++ b/test/parallel/test-tls-ocsp-callback.js @@ -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 ' + @@ -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; @@ -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 @@ -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 ? @@ -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 } |