@@ -10,7 +10,9 @@ const fsPromises = fs.promises;
1010const {
1111 access,
1212 chmod,
13+ chown,
1314 copyFile,
15+ lchown,
1416 link,
1517 lchmod,
1618 lstat,
@@ -107,6 +109,33 @@ function verifyStatObject(stat) {
107109 await chmod ( dest , ( 0o10777 ) ) ;
108110 await handle . chmod ( 0o10777 ) ;
109111
112+ if ( ! common . isWindows ) {
113+ await chown ( dest , process . getuid ( ) , process . getgid ( ) ) ;
114+ await handle . chown ( process . getuid ( ) , process . getgid ( ) ) ;
115+ }
116+
117+ assert . rejects (
118+ async ( ) => {
119+ await chown ( dest , 1 , - 1 ) ;
120+ } ,
121+ {
122+ code : 'ERR_OUT_OF_RANGE' ,
123+ name : 'RangeError [ERR_OUT_OF_RANGE]' ,
124+ message : 'The value of "gid" is out of range. ' +
125+ 'It must be >= 0 && < 4294967296. Received -1'
126+ } ) ;
127+
128+ assert . rejects (
129+ async ( ) => {
130+ await handle . chown ( 1 , - 1 ) ;
131+ } ,
132+ {
133+ code : 'ERR_OUT_OF_RANGE' ,
134+ name : 'RangeError [ERR_OUT_OF_RANGE]' ,
135+ message : 'The value of "gid" is out of range. ' +
136+ 'It must be >= 0 && < 4294967296. Received -1'
137+ } ) ;
138+
110139 await utimes ( dest , new Date ( ) , new Date ( ) ) ;
111140
112141 try {
@@ -130,6 +159,9 @@ function verifyStatObject(stat) {
130159 if ( common . canCreateSymLink ( ) ) {
131160 const newLink = path . resolve ( tmpDir , 'baz3.js' ) ;
132161 await symlink ( newPath , newLink ) ;
162+ if ( ! common . isWindows ) {
163+ await lchown ( newLink , process . getuid ( ) , process . getgid ( ) ) ;
164+ }
133165 stats = await lstat ( newLink ) ;
134166 verifyStatObject ( stats ) ;
135167
0 commit comments