@@ -81,5 +81,46 @@ describe('gitleaks', () => {
81
81
expect ( logStub . calledWith ( 'gitleaks is disabled, skipping' ) ) . to . be . true ;
82
82
} ) ;
83
83
84
+ it ( 'should handle successful scan with no findings' , async ( ) => {
85
+ stubs . getAPIs . returns ( { gitleaks : { enabled : true } } ) ;
86
+
87
+ const gitRootCommitMock = {
88
+ exitCode : 0 ,
89
+ stdout : 'rootcommit123\n' ,
90
+ stderr : ''
91
+ } ;
92
+
93
+ const gitleaksMock = {
94
+ exitCode : 0 ,
95
+ stdout : '' ,
96
+ stderr : 'No leaks found'
97
+ } ;
98
+
99
+ stubs . spawn
100
+ . onFirstCall ( ) . returns ( {
101
+ on : ( event , cb ) => {
102
+ if ( event === 'close' ) cb ( gitRootCommitMock . exitCode ) ;
103
+ return { stdout : { on : ( ) => { } } , stderr : { on : ( ) => { } } } ;
104
+ } ,
105
+ stdout : { on : ( _ , cb ) => cb ( gitRootCommitMock . stdout ) } ,
106
+ stderr : { on : ( _ , cb ) => cb ( gitRootCommitMock . stderr ) }
107
+ } )
108
+ . onSecondCall ( ) . returns ( {
109
+ on : ( event , cb ) => {
110
+ if ( event === 'close' ) cb ( gitleaksMock . exitCode ) ;
111
+ return { stdout : { on : ( ) => { } } , stderr : { on : ( ) => { } } } ;
112
+ } ,
113
+ stdout : { on : ( _ , cb ) => cb ( gitleaksMock . stdout ) } ,
114
+ stderr : { on : ( _ , cb ) => cb ( gitleaksMock . stderr ) }
115
+ } ) ;
116
+
117
+ const result = await exec ( req , action ) ;
118
+
119
+ expect ( result . error ) . to . be . false ;
120
+ expect ( result . steps ) . to . have . lengthOf ( 1 ) ;
121
+ expect ( result . steps [ 0 ] . error ) . to . be . false ;
122
+ expect ( logStub . calledWith ( 'succeded' ) ) . to . be . true ;
123
+ expect ( logStub . calledWith ( 'No leaks found' ) ) . to . be . true ;
124
+ } ) ;
84
125
} ) ;
85
126
} ) ;
0 commit comments