1'use strict'; 2const common = require('../common'); 3 4if (!common.hasCrypto) 5 common.skip('missing crypto'); 6 7// Test that `tls.Server` constructor options are passed to the parent 8// constructor. 9 10const assert = require('assert'); 11const fixtures = require('../common/fixtures'); 12const tls = require('tls'); 13 14const options = { 15 key: fixtures.readKey('agent1-key.pem'), 16 cert: fixtures.readKey('agent1-cert.pem'), 17}; 18 19{ 20 const server = tls.createServer(options, common.mustCall((socket) => { 21 assert.strictEqual(socket.allowHalfOpen, false); 22 assert.strictEqual(socket.isPaused(), false); 23 })); 24 25 assert.strictEqual(server.allowHalfOpen, false); 26 assert.strictEqual(server.pauseOnConnect, false); 27 28 server.listen(0, common.mustCall(() => { 29 const socket = tls.connect({ 30 port: server.address().port, 31 rejectUnauthorized: false 32 }, common.mustCall(() => { 33 socket.end(); 34 })); 35 36 socket.on('close', () => { 37 server.close(); 38 }); 39 })); 40} 41 42{ 43 const server = tls.createServer({ 44 allowHalfOpen: true, 45 pauseOnConnect: true, 46 ...options 47 }, common.mustCall((socket) => { 48 assert.strictEqual(socket.allowHalfOpen, true); 49 assert.strictEqual(socket.isPaused(), true); 50 socket.on('end', socket.end); 51 })); 52 53 assert.strictEqual(server.allowHalfOpen, true); 54 assert.strictEqual(server.pauseOnConnect, true); 55 56 server.listen(0, common.mustCall(() => { 57 const socket = tls.connect({ 58 port: server.address().port, 59 rejectUnauthorized: false 60 }, common.mustCall(() => { 61 socket.end(); 62 })); 63 64 socket.on('close', () => { 65 server.close(); 66 }); 67 })); 68} 69