-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
https: make opts optional & immutable when create #13599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
26d4efb
2c7ff7b
b3a1ac6
9414765
c798af8
5de8cf2
dc2291c
2232fad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,18 +9,28 @@ const tls = require('tls'); | |
| const dftProtocol = {}; | ||
| tls.convertNPNProtocols([ 'http/1.1' ], dftProtocol); | ||
|
|
||
| // test for immutable `opts` | ||
| const opts = { foo: 'bar', NPNProtocols: [ 'http/1.1' ] }; | ||
| const server1 = https.createServer(opts); | ||
|
|
||
| assert.deepStrictEqual(opts, { foo: 'bar', NPNProtocols: [ 'http/1.1' ] }); | ||
| assert.strictEqual(server1.NPNProtocols.compare(dftProtocol.NPNProtocols), 0); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should suffice to just compare the assert.strictEqual(server1.NPNProtocols, dftProtocol.NPNProtocols);
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mscdex I think we can't, because
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok I see it now. Perhaps we should at least choose a different set of protocols then, so as to differentiate from the default NPN protocols (perhaps just use one protocol?). |
||
|
|
||
|
|
||
| // validate that `createServer` can work with the only argument requestListener | ||
| const mustNotCall = common.mustNotCall(); | ||
| const server2 = https.createServer(mustNotCall); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment below doesn't match the behavior of this line. If we're testing no arguments, it should just be Otherwise we could add a separate test below for no arguments. |
||
|
|
||
| // validate that `createServer` can work with no arguments | ||
| tls.convertNPNProtocols([ 'http/1.1', 'http/1.0' ], dftProtocol); | ||
| assert.ok(server2); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: It doesn't harm but I think this is redundant. An error would be thrown below if
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @refack, Shall I?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| assert.strictEqual(server2.NPNProtocols.compare(dftProtocol.NPNProtocols), 0); | ||
| assert.strictEqual(server2.listeners('request').length, 1); | ||
| assert.strictEqual(server2.listeners('request')[0], mustNotCall); | ||
|
|
||
|
|
||
| // validate that `createServer` can work with no arguments | ||
| const server3 = https.createServer(); | ||
|
|
||
| assert.ok(server3); | ||
| assert.strictEqual(server3.NPNProtocols.compare(dftProtocol.NPNProtocols), 0); | ||
| assert.strictEqual(server3.listeners('request').length, 0); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny nit: instead of using
server1,server2, andserver3we can use block scope.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a style we now use more often (helps frame every test case), but IMHO it's up to you...