mirror of
https://github.com/nodejs/node.git
synced 2025-05-11 11:17:18 +00:00

Added a test to ensure input validation for FD and mode for fs.fchmod. Removed check for values lower than 0 for `mode` as it's already checked by `validateUint32`. PR-URL: https://github.com/nodejs/node/pull/18217 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net>
58 lines
1.2 KiB
JavaScript
58 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const fs = require('fs');
|
|
|
|
['', false, null, undefined, {}, [], Infinity, -1].forEach((i) => {
|
|
common.expectsError(
|
|
() => fs.fchown(i),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message: 'The "fd" argument must be of type integer'
|
|
}
|
|
);
|
|
common.expectsError(
|
|
() => fs.fchownSync(i),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message: 'The "fd" argument must be of type integer'
|
|
}
|
|
);
|
|
|
|
common.expectsError(
|
|
() => fs.fchown(1, i),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message: 'The "uid" argument must be of type integer'
|
|
}
|
|
);
|
|
common.expectsError(
|
|
() => fs.fchownSync(1, i),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message: 'The "uid" argument must be of type integer'
|
|
}
|
|
);
|
|
|
|
common.expectsError(
|
|
() => fs.fchown(1, 1, i),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message: 'The "gid" argument must be of type integer'
|
|
}
|
|
);
|
|
common.expectsError(
|
|
() => fs.fchownSync(1, 1, i),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message: 'The "gid" argument must be of type integer'
|
|
}
|
|
);
|
|
});
|