@@ -145,6 +145,41 @@ describe('admin router', () => {
145145 expect ( response . status ) . to . equal ( 401 )
146146 } )
147147
148+ it ( 'returns 500 when SECRET is missing during login' , async ( ) => {
149+ delete process . env . SECRET
150+ process . env . ADMIN_PASSWORD = 'correct-password'
151+ const baseUrl = await startServer ( { admin : { enabled : true } } )
152+
153+ const response = await axios . post (
154+ `${ baseUrl } /login` ,
155+ { password : 'correct-password' } ,
156+ {
157+ headers : { 'content-type' : 'application/json' } ,
158+ validateStatus : ( ) => true ,
159+ } ,
160+ )
161+
162+ expect ( response . status ) . to . equal ( 500 )
163+ expect ( response . data ) . to . deep . equal ( { error : 'Internal Server Error' } )
164+
165+ process . env . SECRET = 'test-admin-secret-value'
166+ } )
167+
168+ it ( 'returns 500 when SECRET is missing during session validation' , async ( ) => {
169+ delete process . env . SECRET
170+ const baseUrl = await startServer ( { admin : { enabled : true } } )
171+
172+ const response = await axios . get ( `${ baseUrl } /session` , {
173+ headers : { cookie : 'admin_session=9999999999.deadbeef' } ,
174+ validateStatus : ( ) => true ,
175+ } )
176+
177+ expect ( response . status ) . to . equal ( 500 )
178+ expect ( response . data ) . to . deep . equal ( { error : 'Internal Server Error' } )
179+
180+ process . env . SECRET = 'test-admin-secret-value'
181+ } )
182+
148183 it ( 'authenticates with ADMIN_PASSWORD and exposes session and health' , async ( ) => {
149184 process . env . ADMIN_PASSWORD = 'correct-password'
150185 const baseUrl = await startServer ( { admin : { enabled : true , sessionTtlSeconds : 3600 } } )
0 commit comments