test: refactor test-tls-inception
* buffer-to-string comparison replaced with string-to-string comparison * equal -> strictEqual * var -> const * rename identifiers to avoid masking PR-URL: https://github.com/nodejs/node/pull/9536 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
f673c97548
commit
9004bfe550
@ -1,34 +1,33 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common');
|
const common = require('../common');
|
||||||
var assert = require('assert');
|
|
||||||
|
|
||||||
if (!common.hasCrypto) {
|
if (!common.hasCrypto) {
|
||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var tls = require('tls');
|
|
||||||
|
|
||||||
var fs = require('fs');
|
const assert = require('assert');
|
||||||
var path = require('path');
|
const tls = require('tls');
|
||||||
var net = require('net');
|
|
||||||
|
|
||||||
var options, a, b;
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const net = require('net');
|
||||||
|
|
||||||
var body = Buffer.alloc(400000, 'A');
|
const options = {
|
||||||
|
|
||||||
options = {
|
|
||||||
key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')),
|
key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')),
|
||||||
cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))
|
cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const body = 'A'.repeat(40000);
|
||||||
|
|
||||||
// the "proxy" server
|
// the "proxy" server
|
||||||
a = tls.createServer(options, function(socket) {
|
const a = tls.createServer(options, function(socket) {
|
||||||
var options = {
|
const myOptions = {
|
||||||
host: '127.0.0.1',
|
host: '127.0.0.1',
|
||||||
port: b.address().port,
|
port: b.address().port,
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
};
|
};
|
||||||
var dest = net.connect(options);
|
const dest = net.connect(myOptions);
|
||||||
dest.pipe(socket);
|
dest.pipe(socket);
|
||||||
socket.pipe(dest);
|
socket.pipe(dest);
|
||||||
|
|
||||||
@ -38,20 +37,19 @@ a = tls.createServer(options, function(socket) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// the "target" server
|
// the "target" server
|
||||||
b = tls.createServer(options, function(socket) {
|
const b = tls.createServer(options, function(socket) {
|
||||||
socket.end(body);
|
socket.end(body);
|
||||||
});
|
});
|
||||||
|
|
||||||
a.listen(0, function() {
|
a.listen(0, function() {
|
||||||
b.listen(0, function() {
|
b.listen(0, function() {
|
||||||
options = {
|
const myOptions = {
|
||||||
host: '127.0.0.1',
|
host: '127.0.0.1',
|
||||||
port: a.address().port,
|
port: a.address().port,
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
};
|
};
|
||||||
var socket = tls.connect(options);
|
const socket = tls.connect(myOptions);
|
||||||
var ssl;
|
const ssl = tls.connect({
|
||||||
ssl = tls.connect({
|
|
||||||
socket: socket,
|
socket: socket,
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
});
|
});
|
||||||
@ -61,7 +59,7 @@ a.listen(0, function() {
|
|||||||
buf += data;
|
buf += data;
|
||||||
});
|
});
|
||||||
ssl.on('end', common.mustCall(function() {
|
ssl.on('end', common.mustCall(function() {
|
||||||
assert.equal(buf, body);
|
assert.strictEqual(buf, body);
|
||||||
ssl.end();
|
ssl.end();
|
||||||
a.close();
|
a.close();
|
||||||
b.close();
|
b.close();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user