@@ -111,21 +111,21 @@ describe("readSecretFileSync", () => {
111111 await expectSecretFileError ( { setup, expectedMessage, options } ) ;
112112 } ) ;
113113
114+ it ( "throws from the try helper for rejected files" , async ( ) => {
115+ const file = await createSecretPath ( async ( dir ) => {
116+ const target = path . join ( dir , "target.txt" ) ;
117+ const link = path . join ( dir , "secret-link.txt" ) ;
118+ await fsPromises . writeFile ( target , "top-secret\n" , "utf8" ) ;
119+ await fsPromises . symlink ( target , link ) ;
120+ return link ;
121+ } ) ;
122+
123+ expect ( ( ) =>
124+ tryReadSecretFileSync ( file , "Telegram bot token" , { rejectSymlink : true } ) ,
125+ ) . toThrow ( `Telegram bot token file at ${ file } must not be a symlink.` ) ;
126+ } ) ;
127+
114128 it . each ( [
115- {
116- name : "returns undefined from the non-throwing helper for rejected files" ,
117- pathValue : async ( ) =>
118- createSecretPath ( async ( dir ) => {
119- const target = path . join ( dir , "target.txt" ) ;
120- const link = path . join ( dir , "secret-link.txt" ) ;
121- await fsPromises . writeFile ( target , "top-secret\n" , "utf8" ) ;
122- await fsPromises . symlink ( target , link ) ;
123- return link ;
124- } ) ,
125- label : "Telegram bot token" ,
126- options : { rejectSymlink : true } ,
127- expected : undefined ,
128- } ,
129129 {
130130 name : "returns undefined from the non-throwing helper for blank file paths" ,
131131 pathValue : async ( ) => " " ,
0 commit comments