mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00

Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> PR-URL: https://github.com/nodejs/node/pull/58517 Reviewed-By: Ethan Arrowood <ethan@arrowood.dev> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
41 lines
906 B
JavaScript
41 lines
906 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { isMainThread } = require('worker_threads');
|
|
|
|
if (!isMainThread) {
|
|
common.skip('This test only works on a main thread');
|
|
}
|
|
|
|
const assert = require('assert');
|
|
const http = require('http');
|
|
const { spawnSync } = require('child_process');
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
const file = fixtures.path('permission', 'net-http.js');
|
|
|
|
const server = http.createServer((req, res) => {
|
|
res.writeHead(200);
|
|
res.end('Hello');
|
|
}).listen(0, common.mustCall(() => {
|
|
const port = server.address().port;
|
|
const url = `http://localhost:${port}`;
|
|
|
|
const { status, stderr } = spawnSync(
|
|
process.execPath,
|
|
[
|
|
'--permission',
|
|
'--allow-fs-read=*',
|
|
file,
|
|
],
|
|
{
|
|
env: {
|
|
...process.env,
|
|
URL: url,
|
|
},
|
|
}
|
|
);
|
|
|
|
server.close();
|
|
assert.strictEqual(status, 0, stderr.toString());
|
|
}));
|