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
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 0 additions & 60 deletions test/disabled/test-child-process-uid-gid.js

This file was deleted.

14 changes: 14 additions & 0 deletions test/parallel/test-child-process-uid-gid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const spawn = require('child_process').spawn;

const expectedError = common.isWindows ? /\bENOTSUP\b/ : /\bEPERM\b/;

assert.throws(() => {
spawn('echo', ['fhqwhgads'], {uid: 0});
}, expectedError, 'Setting UID should throw EPERM for unprivileged users.');

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.