|
| 1 | +'use strict'; |
| 2 | +const common = require('../common'); |
| 3 | + |
| 4 | +if (!common.hasCrypto) |
| 5 | + common.skip('missing crypto'); |
| 6 | + |
| 7 | +// Test that `tls.Server` constructor options are passed to the parent |
| 8 | +// constructor. |
| 9 | + |
| 10 | +const assert = require('assert'); |
| 11 | +const fixtures = require('../common/fixtures'); |
| 12 | +const tls = require('tls'); |
| 13 | + |
| 14 | +const 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 | + })); |
| 23 | + |
| 24 | + assert.strictEqual(server.allowHalfOpen, false); |
| 25 | + |
| 26 | + server.listen(0, common.mustCall(() => { |
| 27 | + const socket = tls.connect({ |
| 28 | + port: server.address().port, |
| 29 | + rejectUnauthorized: false |
| 30 | + }, common.mustCall(() => { |
| 31 | + socket.end(); |
| 32 | + })); |
| 33 | + |
| 34 | + socket.on('close', () => { |
| 35 | + server.close(); |
| 36 | + }); |
| 37 | + })); |
| 38 | +} |
| 39 | + |
| 40 | +{ |
| 41 | + const server = tls.createServer({ |
| 42 | + allowHalfOpen: true, |
| 43 | + ...options |
| 44 | + }, common.mustCall((socket) => { |
| 45 | + assert.strictEqual(socket.allowHalfOpen, true); |
| 46 | + socket.on('end', socket.end); |
| 47 | + })); |
| 48 | + |
| 49 | + assert.strictEqual(server.allowHalfOpen, true); |
| 50 | + |
| 51 | + server.listen(0, common.mustCall(() => { |
| 52 | + const socket = tls.connect({ |
| 53 | + port: server.address().port, |
| 54 | + rejectUnauthorized: false |
| 55 | + }, common.mustCall(() => { |
| 56 | + socket.end(); |
| 57 | + })); |
| 58 | + |
| 59 | + socket.on('close', () => { |
| 60 | + server.close(); |
| 61 | + }); |
| 62 | + })); |
| 63 | +} |
0 commit comments