@@ -64,6 +64,40 @@ describe('Permission model config file support', () => {
6464 }
6565 } ) ;
6666
67+ it ( 'should propagate config file permissions to child processes' , {
68+ skip : process . config . variables . node_without_node_options && 'missing NODE_OPTIONS support' ,
69+ } , async ( ) => {
70+ const childTestPath = fixtures . path ( 'permission/child-process-inherit-test.js' ) ;
71+ const expected = JSON . stringify ( [ 'object' , true , false , true , true ] ) ;
72+
73+ // --permission set in the config file
74+ {
75+ const configPath = fixtures . path ( 'permission/config-child-inherit.json' ) ;
76+ const result = await spawnPromisified ( process . execPath , [
77+ `--config-file=${ configPath } ` ,
78+ childTestPath ,
79+ ] ) ;
80+ assert . strictEqual ( result . code , 0 , result . stderr ) ;
81+ const child = JSON . parse ( result . stdout ) ;
82+ assert . strictEqual ( child . status , 0 , child . stderr ) ;
83+ assert . strictEqual ( child . stdout , expected ) ;
84+ }
85+
86+ // --permission set in the command line
87+ {
88+ const configPath = fixtures . path ( 'permission/config-child-inherit-allow-only.json' ) ;
89+ const result = await spawnPromisified ( process . execPath , [
90+ '--permission' ,
91+ `--config-file=${ configPath } ` ,
92+ childTestPath ,
93+ ] ) ;
94+ assert . strictEqual ( result . code , 0 , result . stderr ) ;
95+ const child = JSON . parse ( result . stdout ) ;
96+ assert . strictEqual ( child . status , 0 , child . stderr ) ;
97+ assert . strictEqual ( child . stdout , expected ) ;
98+ }
99+ } ) ;
100+
67101 it ( 'should load network and inspector permissions from config file' , async ( ) => {
68102 const configPath = fixtures . path ( 'permission/config-net-inspector.json' ) ;
69103 const readOnlyConfigPath = fixtures . path ( 'permission/config-fs-read-only.json' ) ;
0 commit comments