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 2 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.

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

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

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.