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