|
| 1 | +'use strict'; |
| 2 | +const common = require('../common'); |
| 3 | +const assert = require('assert'); |
| 4 | + |
| 5 | +if (common.isWindows || !common.isMainThread) { |
| 6 | + assert.strictEqual(process.initgroups, undefined); |
| 7 | + return; |
| 8 | +} |
| 9 | + |
| 10 | +[undefined, null, true, {}, [], () => {}].forEach((val) => { |
| 11 | + assert.throws( |
| 12 | + () => { |
| 13 | + process.initgroups(val); |
| 14 | + }, |
| 15 | + { |
| 16 | + code: 'ERR_INVALID_ARG_TYPE', |
| 17 | + name: 'TypeError [ERR_INVALID_ARG_TYPE]', |
| 18 | + message: |
| 19 | + 'The "user" argument must be ' + |
| 20 | + 'one of type number or string. ' + |
| 21 | + `Received type ${typeof val}` |
| 22 | + } |
| 23 | + ); |
| 24 | +}); |
| 25 | + |
| 26 | +[undefined, null, true, {}, [], () => {}].forEach((val) => { |
| 27 | + assert.throws( |
| 28 | + () => { |
| 29 | + process.initgroups('foo', val); |
| 30 | + }, |
| 31 | + { |
| 32 | + code: 'ERR_INVALID_ARG_TYPE', |
| 33 | + name: 'TypeError [ERR_INVALID_ARG_TYPE]', |
| 34 | + message: |
| 35 | + 'The "extraGroup" argument must be ' + |
| 36 | + 'one of type number or string. ' + |
| 37 | + `Received type ${typeof val}` |
| 38 | + } |
| 39 | + ); |
| 40 | +}); |
| 41 | + |
| 42 | +assert.throws( |
| 43 | + () => { |
| 44 | + process.initgroups( |
| 45 | + 'fhqwhgadshgnsdhjsdbkhsdabkfabkveyb', |
| 46 | + 'fhqwhgadshgnsdhjsdbkhsdabkfabkveyb' |
| 47 | + ); |
| 48 | + }, |
| 49 | + { |
| 50 | + code: 'ERR_UNKNOWN_CREDENTIAL', |
| 51 | + message: |
| 52 | + 'Group identifier does not exist: fhqwhgadshgnsdhjsdbkhsdabkfabkveyb' |
| 53 | + } |
| 54 | +); |
0 commit comments