Skip to content
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

test: added net.connect lookup type check #11873

Closed

Conversation

lucamaraschi
Copy link
Contributor

Check the options passed to the Socket connect function to validate
the type of the lookup property. It must be strictly a function.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

test net

Check the options passed to the connect function of Socket to validate
the type of the lookupmproperty. It must be strictly a function.
@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Mar 15, 2017
Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Few nits.


const expectedError = /^TypeError: "lookup" option should be a function$/;

['foobar', 1, {}, []].forEach((input => { connectThrows(input); }))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a ; at the end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also.. the { and ; } around connectThrows(input) can be dropped.

['foobar', 1, {}, []].forEach((input => { connectThrows(input); }))

function connectThrows(input) {
var opts = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/var/const

@@ -5,10 +5,10 @@ const net = require('net');

const expectedError = /^TypeError: "lookup" option should be a function$/;

['foobar', 1, {}, []].forEach((input => { connectThrows(input); }))
['foobar', 1, {}, []].forEach((input => connectThrows(input) ));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the extra parens around the arrow function here and on line 22 be removed?

@cjihrig
Copy link
Contributor

cjihrig commented Mar 16, 2017

@mscdex mscdex added the net Issues and PRs related to the net subsystem. label Mar 16, 2017
const opts = {
host: 'localhost',
port: common.PORT,
lookup: input,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should remove the comma here. Is this passing make lint?

const opts = {
host: 'localhost',
port: common.PORT,
lookup: input,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here


const expectedError = /^TypeError: "lookup" option should be a function$/;

['foobar', 1, {}, []].forEach((input) => connectThrows(input));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: how about adding other primitives (boolean, undefined, symbol)?

@jasnell
Copy link
Member

jasnell commented Mar 17, 2017

@cjihrig
Copy link
Contributor

cjihrig commented Mar 20, 2017

Landed in 1ff6796. Thanks.

@cjihrig cjihrig closed this Mar 20, 2017
cjihrig pushed a commit that referenced this pull request Mar 20, 2017
Check the options passed to Socket.prototype.connect() to
validate the type of the lookup property.

PR-URL: #11873
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
jungx098 pushed a commit to jungx098/node that referenced this pull request Mar 21, 2017
Check the options passed to Socket.prototype.connect() to
validate the type of the lookup property.

PR-URL: nodejs#11873
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
@italoacasas
Copy link
Contributor

This PR need backport to v7

@gibfahn
Copy link
Member

gibfahn commented Jun 20, 2017

Landed cleanly on v6.x (it's a new file, not sure why it needed a backport to v7).

gibfahn pushed a commit that referenced this pull request Jun 20, 2017
Check the options passed to Socket.prototype.connect() to
validate the type of the lookup property.

PR-URL: #11873
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jul 11, 2017
Check the options passed to Socket.prototype.connect() to
validate the type of the lookup property.

PR-URL: #11873
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Jul 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
net Issues and PRs related to the net subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.