mirror of
https://github.com/nodejs/node.git
synced 2025-04-28 21:46:48 +00:00

Move permission model from 1.1 (Active Development) to 2.0 (Stable). PR-URL: https://github.com/nodejs/node/pull/56201 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
// Flags: --permission --allow-fs-read=* --allow-child-process
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
common.skipIfWorker();
|
|
|
|
const assert = require('assert');
|
|
const { spawnSync } = require('child_process');
|
|
|
|
if (!common.isWindows) {
|
|
common.skip('windows UNC path test');
|
|
}
|
|
|
|
{
|
|
const { stdout, status } = spawnSync(process.execPath, [
|
|
'--permission', '--allow-fs-write', 'C:\\\\', '-e',
|
|
'console.log(process.permission.has("fs.write", "C:\\\\"))',
|
|
]);
|
|
assert.strictEqual(stdout.toString(), 'true\n');
|
|
assert.strictEqual(status, 0);
|
|
}
|
|
|
|
{
|
|
const { stdout, status, stderr } = spawnSync(process.execPath, [
|
|
'--permission', '--allow-fs-write="\\\\?\\C:\\"', '-e',
|
|
'console.log(process.permission.has("fs.write", "C:\\\\"))',
|
|
]);
|
|
assert.strictEqual(stdout.toString(), 'false\n', stderr.toString());
|
|
assert.strictEqual(status, 0);
|
|
}
|
|
|
|
{
|
|
const { stdout, status, stderr } = spawnSync(process.execPath, [
|
|
'--permission', '--allow-fs-write', 'C:\\', '-e',
|
|
`const path = require('path');
|
|
console.log(process.permission.has('fs.write', path.toNamespacedPath('C:\\\\')))`,
|
|
]);
|
|
assert.strictEqual(stdout.toString(), 'true\n', stderr.toString());
|
|
assert.strictEqual(status, 0);
|
|
}
|
|
|
|
{
|
|
const { stdout, status, stderr } = spawnSync(process.execPath, [
|
|
'--permission', '--allow-fs-write', 'C:\\*', '-e',
|
|
"console.log(process.permission.has('fs.write', '\\\\\\\\A\\\\C:\\Users'))",
|
|
]);
|
|
assert.strictEqual(stdout.toString(), 'false\n', stderr.toString());
|
|
assert.strictEqual(status, 0);
|
|
}
|