0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-permission-inspector.js
Rafael Gonzaga 14e7bd84f1
src,permission: restrict by default when pm enabled
PR-URL: https://github.com/nodejs/node/pull/48907
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2023-07-26 18:32:03 +00:00

37 lines
850 B
JavaScript

// Flags: --experimental-permission --allow-fs-read=* --allow-child-process
'use strict';
const common = require('../common');
common.skipIfWorker();
common.skipIfInspectorDisabled();
const { Session } = require('inspector');
const assert = require('assert');
const { spawnSync } = require('child_process');
if (!common.hasCrypto)
common.skip('no crypto');
{
assert.throws(() => {
const session = new Session();
session.connect();
}, common.expectsError({
code: 'ERR_ACCESS_DENIED',
permission: 'Inspector',
}));
}
{
const { status, stderr } = spawnSync(
process.execPath,
[
'--experimental-permission',
'-e',
'(new (require("inspector")).Session()).connect()',
],
);
assert.strictEqual(status, 1);
assert.match(stderr.toString(), /Error: Access to this API has been restricted/);
}