@@ -209,6 +209,54 @@ test('proxy API key authentication is optional and uses exact bearer tokens', ()
209209 assert . equal ( serverInternals . isProxyAuthorized ( 'Bearer secret ' , 'secret' ) , false ) ;
210210} ) ;
211211
212+ test ( 'proxy API key can be loaded from a mounted secret and required explicitly' , ( ) => {
213+ const dir = tmpdir ( ) ;
214+ const secretPath = path . join ( dir , 'proxy-api-key' ) ;
215+ fs . writeFileSync ( secretPath , 'mounted-secret\n' ) ;
216+
217+ assert . equal ( serverInternals . loadProxyApiKey ( { PROXY_API_KEY_FILE : secretPath } ) , 'mounted-secret' ) ;
218+ assert . equal ( serverInternals . loadProxyApiKey ( { PROXY_API_KEY : 'env-secret' , PROXY_API_KEY_FILE : secretPath } ) , 'env-secret' ) ;
219+ assert . equal ( serverInternals . loadProxyApiKey ( { PROXY_API_KEY_FILE : path . join ( dir , 'missing' ) } ) , '' ) ;
220+ assert . doesNotThrow ( ( ) => serverInternals . requireProxyApiKey ( 'mounted-secret' , true ) ) ;
221+ assert . throws (
222+ ( ) => serverInternals . requireProxyApiKey ( '' , true ) ,
223+ / P R O X Y _ A P I _ K E Y i s r e q u i r e d / ,
224+ ) ;
225+ } ) ;
226+
227+ test ( 'Containerfile keeps the rootless Podman runtime minimal and fail-closed' , ( ) => {
228+ const containerfile = fs . readFileSync ( path . join ( ROOT , 'Containerfile' ) , 'utf8' ) ;
229+ const containerignore = fs . readFileSync ( path . join ( ROOT , '.containerignore' ) , 'utf8' ) ;
230+ const readme = fs . readFileSync ( path . join ( ROOT , 'README.md' ) , 'utf8' ) ;
231+ const copyLines = containerfile
232+ . split ( / \r ? \n / )
233+ . map ( line => line . trim ( ) )
234+ . filter ( line => line . startsWith ( 'COPY ' ) ) ;
235+
236+ assert . deepEqual ( copyLines , [
237+ 'COPY --chown=1000:1000 package.json server.js ./' ,
238+ 'COPY --chown=1000:1000 lib/pow.js ./lib/pow.js' ,
239+ ] ) ;
240+ assert . doesNotMatch ( containerfile , / ^ \s * (?: C O P Y | A D D ) \s + \. \s / m) ;
241+ assert . match ( containerfile , / ^ U S E R 1 0 0 0 : 1 0 0 0 $ / m) ;
242+ assert . match ( containerfile , / H O S T = 0 \. 0 \. 0 \. 0 / ) ;
243+ assert . match ( containerfile , / N O N _ I N T E R A C T I V E = 1 / ) ;
244+ assert . match ( containerfile , / R E Q U I R E _ P R O X Y _ A P I _ K E Y = 1 / ) ;
245+ assert . match ( containerfile , / P R O X Y _ A P I _ K E Y _ F I L E = \/ r u n \/ s e c r e t s \/ p r o x y - a p i - k e y / ) ;
246+ assert . match ( containerfile , / ^ H E A L T H C H E C K / m) ;
247+ assert . match ( containerfile , / p a t h : ' \/ h e a l t h ' / ) ;
248+ assert . match ( containerfile , / ^ C M D \[ " n o d e " , " s e r v e r \. j s " \] $ / m) ;
249+
250+ assert . match ( containerignore , / ^ \* $ / m) ;
251+ assert . doesNotMatch ( containerignore , / ^ ! .* (?: a u t h | s e c r e t | \. e n v ) / mi) ;
252+ assert . match ( readme , / - - p u b l i s h 1 2 7 \. 0 \. 0 \. 1 : 9 6 5 5 : 9 6 5 5 / ) ;
253+ assert . match ( readme , / - - s e c r e t f r e e - d e e p s e e k - a u t h [ ^ \n ] * m o d e = 0 4 0 0 / ) ;
254+ assert . match ( readme , / - - s e c r e t f r e e - d e e p s e e k - p r o x y - k e y [ ^ \n ] * m o d e = 0 4 0 0 / ) ;
255+ assert . match ( readme , / - - r e a d - o n l y / ) ;
256+ assert . match ( readme , / - - c a p - d r o p = A L L / ) ;
257+ assert . match ( readme , / - - s e c u r i t y - o p t = n o - n e w - p r i v i l e g e s / ) ;
258+ } ) ;
259+
212260test ( 'loopback host detection covers supported local bind addresses' , ( ) => {
213261 assert . equal ( serverInternals . isLoopbackHost ( '127.0.0.1' ) , true ) ;
214262 assert . equal ( serverInternals . isLoopbackHost ( '::1' ) , true ) ;
0 commit comments