@@ -205,6 +205,44 @@ describe('gitleaks', () => {
205
205
expect ( stepSpy . calledWith ( 'failed to run gitleaks, please contact an administrator\n' ) ) . to . be . true ;
206
206
} ) ;
207
207
208
+ it ( 'should handle gitleaks spawn failure' , async ( ) => {
209
+ stubs . getAPIs . returns ( { gitleaks : { enabled : true } } ) ;
210
+ stubs . spawn . onFirstCall ( ) . throws ( new Error ( 'Spawn error' ) ) ;
211
+
212
+ const result = await exec ( req , action ) ;
213
+
214
+ expect ( result . error ) . to . be . true ;
215
+ expect ( result . steps ) . to . have . lengthOf ( 1 ) ;
216
+ expect ( result . steps [ 0 ] . error ) . to . be . true ;
217
+ expect ( stepSpy . calledWith ( 'failed to spawn gitleaks, please contact an administrator\n' ) ) . to . be . true ;
218
+ } ) ;
219
+
220
+ it ( 'should handle empty gitleaks entry in proxy.config.json' , async ( ) => {
221
+ stubs . getAPIs . returns ( { gitleaks : { } } ) ;
222
+ const result = await exec ( req , action ) ;
223
+ expect ( result . error ) . to . be . false ;
224
+ expect ( result . steps ) . to . have . lengthOf ( 1 ) ;
225
+ expect ( result . steps [ 0 ] . error ) . to . be . false ;
226
+ } ) ;
227
+
228
+ it ( 'should handle invalid gitleaks entry in proxy.config.json' , async ( ) => {
229
+ stubs . getAPIs . returns ( { gitleaks : 'invalid config' } ) ;
230
+ stubs . spawn . onFirstCall ( ) . returns ( {
231
+ on : ( event , cb ) => {
232
+ if ( event === 'close' ) cb ( 0 ) ;
233
+ return { stdout : { on : ( ) => { } } , stderr : { on : ( ) => { } } } ;
234
+ } ,
235
+ stdout : { on : ( _ , cb ) => cb ( '' ) } ,
236
+ stderr : { on : ( _ , cb ) => cb ( '' ) }
237
+ } ) ;
238
+
239
+ const result = await exec ( req , action ) ;
240
+
241
+ expect ( result . error ) . to . be . false ;
242
+ expect ( result . steps ) . to . have . lengthOf ( 1 ) ;
243
+ expect ( result . steps [ 0 ] . error ) . to . be . false ;
244
+ } ) ;
245
+
208
246
it ( 'should handle custom config path' , async ( ) => {
209
247
stubs . getAPIs . returns ( {
210
248
gitleaks : {
0 commit comments