mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 15:35:41 +00:00

Pass `tls.Server` constructor options to the parent constructor. PR-URL: https://github.com/nodejs/node/pull/27665 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
64 lines
1.4 KiB
JavaScript
64 lines
1.4 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
// Test that `tls.Server` constructor options are passed to the parent
|
|
// constructor.
|
|
|
|
const assert = require('assert');
|
|
const fixtures = require('../common/fixtures');
|
|
const tls = require('tls');
|
|
|
|
const options = {
|
|
key: fixtures.readKey('agent1-key.pem'),
|
|
cert: fixtures.readKey('agent1-cert.pem'),
|
|
};
|
|
|
|
{
|
|
const server = tls.createServer(options, common.mustCall((socket) => {
|
|
assert.strictEqual(socket.allowHalfOpen, false);
|
|
}));
|
|
|
|
assert.strictEqual(server.allowHalfOpen, false);
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
const socket = tls.connect({
|
|
port: server.address().port,
|
|
rejectUnauthorized: false
|
|
}, common.mustCall(() => {
|
|
socket.end();
|
|
}));
|
|
|
|
socket.on('close', () => {
|
|
server.close();
|
|
});
|
|
}));
|
|
}
|
|
|
|
{
|
|
const server = tls.createServer({
|
|
allowHalfOpen: true,
|
|
...options
|
|
}, common.mustCall((socket) => {
|
|
assert.strictEqual(socket.allowHalfOpen, true);
|
|
socket.on('end', socket.end);
|
|
}));
|
|
|
|
assert.strictEqual(server.allowHalfOpen, true);
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
const socket = tls.connect({
|
|
port: server.address().port,
|
|
rejectUnauthorized: false
|
|
}, common.mustCall(() => {
|
|
socket.end();
|
|
}));
|
|
|
|
socket.on('close', () => {
|
|
server.close();
|
|
});
|
|
}));
|
|
}
|