| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a1e3967 commit f44e828
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,17 +1,17 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - var common = require('../common'); | ||
| 3 | - var assert = require('assert'); | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | 4 | ||
| 5 | 5 | if (!common.hasCrypto) { | |
| 6 | 6 | common.skip('missing crypto'); | |
| 7 | 7 | return; | |
| 8 | 8 | } | |
| 9 | - var tls = require('tls'); | ||
| 9 | + const tls = require('tls'); | ||
| 10 | 10 | ||
| 11 | - var fs = require('fs'); | ||
| 11 | + const fs = require('fs'); | ||
| 12 | 12 | ||
| 13 | - var hosterr = /Hostname\/IP doesn\'t match certificate\'s altnames/g; | ||
| 14 | - var testCases = | ||
| 13 | + const hosterr = /Hostname\/IP doesn't match certificate's altnames/g; | ||
| 14 | + const testCases = | ||
| 15 | 15 | [{ ca: ['ca1-cert'], | |
| 16 | 16 | key: 'agent2-key', | |
| 17 | 17 | cert: 'agent2-cert', | |
@@ -52,16 +52,16 @@ function loadPEM(n) { | |||
| 52 | 52 | return fs.readFileSync(filenamePEM(n)); | |
| 53 | 53 | } | |
| 54 | 54 | ||
| 55 | - var successfulTests = 0; | ||
| 55 | + let successfulTests = 0; | ||
| 56 | 56 | ||
| 57 | 57 | function testServers(index, servers, clientOptions, cb) { | |
| 58 | - var serverOptions = servers[index]; | ||
| 58 | + const serverOptions = servers[index]; | ||
| 59 | 59 | if (!serverOptions) { | |
| 60 | 60 | cb(); | |
| 61 | 61 | return; | |
| 62 | 62 | } | |
| 63 | 63 | ||
| 64 | - var ok = serverOptions.ok; | ||
| 64 | + const ok = serverOptions.ok; | ||
| 65 | 65 | ||
| 66 | 66 | if (serverOptions.key) { | |
| 67 | 67 | serverOptions.key = loadPEM(serverOptions.key); | |
@@ -71,45 +71,45 @@ function testServers(index, servers, clientOptions, cb) { | |||
| 71 | 71 | serverOptions.cert = loadPEM(serverOptions.cert); | |
| 72 | 72 | } | |
| 73 | 73 | ||
| 74 | - var server = tls.createServer(serverOptions, function(s) { | ||
| 74 | + const server = tls.createServer(serverOptions, common.mustCall(function(s) { | ||
| 75 | 75 | s.end('hello world\n'); | |
| 76 | - }); | ||
| 76 | + })); | ||
| 77 | 77 | ||
| 78 | - server.listen(0, function() { | ||
| 79 | - var b = ''; | ||
| 78 | + server.listen(0, common.mustCall(function() { | ||
| 79 | + let b = ''; | ||
| 80 | 80 | ||
| 81 | 81 | console.error('connecting...'); | |
| 82 | 82 | clientOptions.port = this.address().port; | |
| 83 | - var client = tls.connect(clientOptions, function() { | ||
| 84 | - var authorized = client.authorized || | ||
| 85 | - hosterr.test(client.authorizationError); | ||
| 83 | + const client = tls.connect(clientOptions, common.mustCall(function() { | ||
| 84 | + const authorized = client.authorized || | ||
| 85 | + hosterr.test(client.authorizationError); | ||
| 86 | 86 | ||
| 87 | 87 | console.error('expected: ' + ok + ' authed: ' + authorized); | |
| 88 | 88 | ||
| 89 | - assert.equal(ok, authorized); | ||
| 89 | + assert.strictEqual(ok, authorized); | ||
| 90 | 90 | server.close(); | |
| 91 | - }); | ||
| 91 | + })); | ||
| 92 | 92 | ||
| 93 | 93 | client.on('data', function(d) { | |
| 94 | 94 | b += d.toString(); | |
| 95 | 95 | }); | |
| 96 | 96 | ||
| 97 | - client.on('end', function() { | ||
| 98 | - assert.equal('hello world\n', b); | ||
| 99 | - }); | ||
| 97 | + client.on('end', common.mustCall(function() { | ||
| 98 | + assert.strictEqual('hello world\n', b); | ||
| 99 | + })); | ||
| 100 | 100 | ||
| 101 | - client.on('close', function() { | ||
| 101 | + client.on('close', common.mustCall(function() { | ||
| 102 | 102 | testServers(index + 1, servers, clientOptions, cb); | |
| 103 | - }); | ||
| 104 | - }); | ||
| 103 | + })); | ||
| 104 | + })); | ||
| 105 | 105 | } | |
| 106 | 106 | ||
| 107 | 107 | ||
| 108 | 108 | function runTest(testIndex) { | |
| 109 | 109 | var tcase = testCases[testIndex]; | |
| 110 | 110 | if (!tcase) return; | |
| 111 | 111 | ||
| 112 | - var clientOptions = { | ||
| 112 | + const clientOptions = { | ||
| 113 | 113 | port: undefined, | |
| 114 | 114 | ca: tcase.ca.map(loadPEM), | |
| 115 | 115 | key: loadPEM(tcase.key), | |
@@ -118,10 +118,10 @@ function runTest(testIndex) { | |||
| 118 | 118 | }; | |
| 119 | 119 | ||
| 120 | 120 | ||
| 121 | - testServers(0, tcase.servers, clientOptions, function() { | ||
| 121 | + testServers(0, tcase.servers, clientOptions, common.mustCall(function() { | ||
| 122 | 122 | successfulTests++; | |
| 123 | 123 | runTest(testIndex + 1); | |
| 124 | - }); | ||
| 124 | + })); | ||
| 125 | 125 | } | |
| 126 | 126 | ||
| 127 | 127 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments