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: add test for uid/gid setting in spawn #7084

Closed
wants to merge 4 commits into from
Closed

Conversation

Trott
Copy link
Member

@Trott Trott commented May 31, 2016

Checklist
  • tests and code linting passes
  • the commit message follows commit guidelines
Affected core subsystem(s)

test child_process

Description of change

Remove a disabled test in favor of one that expects an error.

This validates (somewhat) that the underlying code is calling the
correct system call for setting UID and GID. Unlike the formerly
disabled test, it does not try to validate that the system UID/GID
setting works.

Remove a disabled test in favor of one that expects an error.

This validates (somewhat) that the underlying code is calling the
correct system call for setting UID and GID. Unlike the formerly
disabled test, it does not try to validate that the system UID/GID
setting works.
@Trott Trott added child_process Issues and PRs related to the child_process subsystem. test Issues and PRs related to the tests. labels May 31, 2016
@Trott
Copy link
Member Author

Trott commented May 31, 2016

Windows might have a surprise on this, so running CI immediately: https://ci.nodejs.org/job/node-test-pull-request/2882/


assert.throws(() => {
spawn('echo', ['fhqwhgads'], {gid: 0});
}, /EPERM/, 'Setting GID should throw EPERM for unprivileged users.');
Copy link
Member

Choose a reason for hiding this comment

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

I'm reasonably sure these are going to fail with ENOTSUP on Windows.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm reasonably sure these are going to fail with ENOTSUP on Windows.

Sure enough: https://ci.nodejs.org/job/node-test-binary-windows/2405/RUN_SUBSET=2,VS_VERSION=vcbt2015,label=win10/tapTestReport/test.tap-23/

Will add a check for common.isWindows and alter the expected error appropriately.

@cjihrig
Copy link
Contributor

cjihrig commented Jun 2, 2016

There is #7049 about spawning echo on Windows. It kind of applies to this PR. Once that landed, I was going to consolidate all the uses of echo in our tests to a common helper.

@Trott
Copy link
Member Author

Trott commented Jun 2, 2016

@Trott
Copy link
Member Author

Trott commented Jun 3, 2016

CI is green. Anyone feel good enough about this to give a LGTM? @nodejs/testing

@Trott
Copy link
Member Author

Trott commented Jun 3, 2016

@cjihrig OK to leave this one as is and wait for the common helper function? Since the command doesn't actually ever get run--spawn throws in this test--it doesn't actually affect the test results.

@cjihrig
Copy link
Contributor

cjihrig commented Jun 3, 2016

Yea, LGTM


assert.throws(() => {
spawn('echo', ['fhqwhgads'], {gid: 0});
}, expectedError, 'Setting GID should throw EPERM for unprivileged users.');
Copy link
Member

Choose a reason for hiding this comment

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

Maybe changing the assert message depending if it's windows or not?

Copy link
Member

Choose a reason for hiding this comment

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

I'd just leave out the message.

Copy link
Member

Choose a reason for hiding this comment

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

+1 for omitting the message.

@santigimeno
Copy link
Member

LGTM with one nit you can ignore.

@bnoordhuis
Copy link
Member

LGTM with a suggestion.

@jasnell
Copy link
Member

jasnell commented Jun 3, 2016

LGTM

Trott added a commit to Trott/io.js that referenced this pull request Jun 3, 2016
Remove a disabled test in favor of one that expects an error.

This validates (somewhat) that the underlying code is calling the
correct system call for setting UID and GID. Unlike the formerly
disabled test, it does not try to validate that the system UID/GID
setting works.

PR-URL: nodejs#7084
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@Trott
Copy link
Member Author

Trott commented Jun 3, 2016

Landed in d015169

@Trott Trott closed this Jun 3, 2016
evanlucas pushed a commit that referenced this pull request Jun 15, 2016
Remove a disabled test in favor of one that expects an error.

This validates (somewhat) that the underlying code is calling the
correct system call for setting UID and GID. Unlike the formerly
disabled test, it does not try to validate that the system UID/GID
setting works.

PR-URL: #7084
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@evanlucas evanlucas mentioned this pull request Jun 16, 2016
@MylesBorins
Copy link
Contributor

@Trott lts?

@Trott
Copy link
Member Author

Trott commented Jul 11, 2016

@thealphanerd If it lands cleanly, yes.

MylesBorins pushed a commit that referenced this pull request Jul 11, 2016
Remove a disabled test in favor of one that expects an error.

This validates (somewhat) that the underlying code is calling the
correct system call for setting UID and GID. Unlike the formerly
disabled test, it does not try to validate that the system UID/GID
setting works.

PR-URL: #7084
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jul 12, 2016
Remove a disabled test in favor of one that expects an error.

This validates (somewhat) that the underlying code is calling the
correct system call for setting UID and GID. Unlike the formerly
disabled test, it does not try to validate that the system UID/GID
setting works.

PR-URL: #7084
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jul 12, 2016
Remove a disabled test in favor of one that expects an error.

This validates (somewhat) that the underlying code is calling the
correct system call for setting UID and GID. Unlike the formerly
disabled test, it does not try to validate that the system UID/GID
setting works.

PR-URL: #7084
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Jul 12, 2016
MylesBorins pushed a commit that referenced this pull request Jul 14, 2016
Remove a disabled test in favor of one that expects an error.

This validates (somewhat) that the underlying code is calling the
correct system call for setting UID and GID. Unlike the formerly
disabled test, it does not try to validate that the system UID/GID
setting works.

PR-URL: #7084
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jul 14, 2016
Remove a disabled test in favor of one that expects an error.

This validates (somewhat) that the underlying code is calling the
correct system call for setting UID and GID. Unlike the formerly
disabled test, it does not try to validate that the system UID/GID
setting works.

PR-URL: #7084
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@Trott Trott deleted the uidgid branch January 13, 2022 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
child_process Issues and PRs related to the child_process subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants