-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass `tls.Server` constructor options to the parent constructor. PR-URL: #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>
- Loading branch information
Showing
3 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
test/parallel/test-tls-server-parent-constructor-options.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
'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(); | ||
}); | ||
})); | ||
} |