Skip to content

Commit 779ab6a

Browse files
test: json config file non readable
1 parent b0568f5 commit 779ab6a

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"max-http-header-size": 10
3+
}

test/parallel/test-config-file.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const { spawnPromisified } = require('../common');
44
const fixtures = require('../common/fixtures');
55
const { match, strictEqual } = require('node:assert');
66
const { test } = require('node:test');
7+
const { chmodSync } = require('node:fs');
78

89
test('should handle non existing json', async () => {
910
const result = await spawnPromisified(process.execPath, [
@@ -282,3 +283,17 @@ test('should override node.json when specificied', async () => {
282283
strictEqual(result.stdout, '20\n');
283284
strictEqual(result.code, 0);
284285
});
286+
287+
test('should throw an error when the file is non readable', async () => {
288+
chmodSync(fixtures.path('rc/non-readable/node.json'), '000');
289+
const result = await spawnPromisified(process.execPath, [
290+
'--no-warnings',
291+
'--experimental-config-file',
292+
'-p', 'http.maxHeaderSize',
293+
], {
294+
cwd: fixtures.path('rc/non-readable'),
295+
});
296+
match(result.stderr, /Cannot read configuration from node\.json: permission denied/);
297+
strictEqual(result.stdout, '');
298+
strictEqual(result.code, 9);
299+
});

0 commit comments

Comments
 (0)