File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,20 @@ mod tests {
133133 temp. close ( ) . unwrap ( ) ;
134134 }
135135
136+ #[ cfg( unix) ]
137+ #[ test]
138+ fn read_json_error_when_permission_denied ( ) -> Result < ( ) > {
139+ use std:: os:: unix:: fs:: PermissionsExt ;
140+ let transport = Transport :: temp ( ) ;
141+ let f = std:: fs:: File :: create ( transport. local_path ( ) . unwrap ( ) . join ( "file" ) ) ?;
142+ let metadata = f. metadata ( ) ?;
143+ let mut perms = metadata. permissions ( ) ;
144+ perms. set_mode ( 0 ) ;
145+ f. set_permissions ( perms) ?;
146+ read_json :: < TestContents > ( & transport, "file" ) . expect_err ( "Read file with access denied" ) ;
147+ Ok ( ( ) )
148+ }
149+
136150 #[ test]
137151 fn read_json_is_none_for_nonexistent_files ( ) {
138152 let transport = Transport :: temp ( ) ;
Original file line number Diff line number Diff line change @@ -240,8 +240,8 @@ impl Transport {
240240 self . protocol . url ( )
241241 }
242242
243- #[ allow( unused) ]
244- fn local_path ( & self ) -> Option < PathBuf > {
243+ #[ allow( unused) ] // exposed for testing
244+ pub fn local_path ( & self ) -> Option < PathBuf > {
245245 self . protocol . local_path ( )
246246 }
247247}
You can’t perform that action at this time.
0 commit comments