@@ -124,70 +124,6 @@ describe('startSecurityScan', function () {
124124 } )
125125 } )
126126
127- it ( 'Should stop security scan for project scans when confirmed' , async function ( ) {
128- getFetchStubWithResponse ( { status : 200 , statusText : 'testing stub' } )
129- const securityScanRenderSpy = sinon . spy ( diagnosticsProvider , 'initSecurityScanRender' )
130- const securityScanStoppedErrorSpy = sinon . spy ( model , 'CodeScanStoppedError' )
131- const testWindow = getTestWindow ( )
132- testWindow . onDidShowMessage ( ( message ) => {
133- if ( message . message === stopScanMessage ) {
134- message . selectItem ( startSecurityScan . stopScanButton )
135- }
136- } )
137- model . codeScanState . setToRunning ( )
138- const scanPromise = startSecurityScan . startSecurityScan (
139- mockSecurityPanelViewProvider ,
140- editor ,
141- createClient ( ) ,
142- extensionContext ,
143- CodeAnalysisScope . PROJECT ,
144- false
145- )
146- await startSecurityScan . confirmStopSecurityScan (
147- model . codeScanState ,
148- false ,
149- CodeAnalysisScope . PROJECT ,
150- undefined
151- )
152- await scanPromise
153- assert . ok ( securityScanRenderSpy . notCalled )
154- assert . ok ( securityScanStoppedErrorSpy . calledOnce )
155- const warnings = testWindow . shownMessages . filter ( ( m ) => m . severity === SeverityLevel . Warning )
156- assert . ok ( warnings . map ( ( m ) => m . message ) . includes ( stopScanMessage ) )
157- } )
158-
159- it ( 'Should not stop security scan for project scans when not confirmed' , async function ( ) {
160- getFetchStubWithResponse ( { status : 200 , statusText : 'testing stub' } )
161- const securityScanRenderSpy = sinon . spy ( diagnosticsProvider , 'initSecurityScanRender' )
162- const securityScanStoppedErrorSpy = sinon . spy ( model , 'CodeScanStoppedError' )
163- const testWindow = getTestWindow ( )
164- testWindow . onDidShowMessage ( ( message ) => {
165- if ( message . message === stopScanMessage ) {
166- message . selectItem ( cancel )
167- }
168- } )
169- model . codeScanState . setToRunning ( )
170- const scanPromise = startSecurityScan . startSecurityScan (
171- mockSecurityPanelViewProvider ,
172- editor ,
173- createClient ( ) ,
174- extensionContext ,
175- CodeAnalysisScope . PROJECT ,
176- false
177- )
178- await startSecurityScan . confirmStopSecurityScan (
179- model . codeScanState ,
180- false ,
181- CodeAnalysisScope . PROJECT ,
182- undefined
183- )
184- await scanPromise
185- assert . ok ( securityScanRenderSpy . calledOnce )
186- assert . ok ( securityScanStoppedErrorSpy . notCalled )
187- const warnings = testWindow . shownMessages . filter ( ( m ) => m . severity === SeverityLevel . Warning )
188- assert . ok ( warnings . map ( ( m ) => m . message ) . includes ( stopScanMessage ) )
189- } )
190-
191127 it ( 'Should stop security scan for auto file scans if setting is disabled' , async function ( ) {
192128 getFetchStubWithResponse ( { status : 200 , statusText : 'testing stub' } )
193129 const securityScanRenderSpy = sinon . spy ( diagnosticsProvider , 'initSecurityScanRender' )
@@ -272,39 +208,6 @@ describe('startSecurityScan', function () {
272208 ] )
273209 } )
274210
275- it ( 'Should not cancel a project scan if a file scan has started' , async function ( ) {
276- getFetchStubWithResponse ( { status : 200 , statusText : 'testing stub' } )
277- await model . CodeScansState . instance . setScansEnabled ( true )
278-
279- const scanPromise = startSecurityScan . startSecurityScan (
280- mockSecurityPanelViewProvider ,
281- editor ,
282- createClient ( ) ,
283- extensionContext ,
284- CodeAnalysisScope . PROJECT ,
285- false
286- )
287- await startSecurityScan . startSecurityScan (
288- mockSecurityPanelViewProvider ,
289- editor ,
290- createClient ( ) ,
291- extensionContext ,
292- CodeAnalysisScope . FILE_AUTO ,
293- false
294- )
295- await scanPromise
296- assertTelemetry ( 'codewhisperer_securityScan' , [
297- {
298- result : 'Succeeded' ,
299- codewhispererCodeScanScope : 'FILE_AUTO' ,
300- } ,
301- {
302- result : 'Succeeded' ,
303- codewhispererCodeScanScope : 'PROJECT' ,
304- } ,
305- ] )
306- } )
307-
308211 it ( 'Should handle failed scan job status' , async function ( ) {
309212 getFetchStubWithResponse ( { status : 200 , statusText : 'testing stub' } )
310213
@@ -330,36 +233,6 @@ describe('startSecurityScan', function () {
330233 } )
331234 } )
332235
333- it ( 'Should show notification when throttled for project scans' , async function ( ) {
334- getFetchStubWithResponse ( { status : 200 , statusText : 'testing stub' } )
335- const mockClient = createClient ( )
336- mockClient . createCodeScan . throws ( {
337- code : 'ThrottlingException' ,
338- time : new Date ( ) ,
339- name : 'error name' ,
340- message : scansLimitReachedErrorMessage ,
341- } satisfies AWSError )
342- sinon . stub ( errors , 'isAwsError' ) . returns ( true )
343- const testWindow = getTestWindow ( )
344- await startSecurityScan . startSecurityScan (
345- mockSecurityPanelViewProvider ,
346- editor ,
347- mockClient ,
348- extensionContext ,
349- CodeAnalysisScope . PROJECT ,
350- false
351- )
352-
353- assert . ok ( testWindow . shownMessages . map ( ( m ) => m . message ) . includes ( monthlyLimitReachedNotification ) )
354- assertTelemetry ( 'codewhisperer_securityScan' , {
355- codewhispererCodeScanScope : 'PROJECT' ,
356- result : 'Failed' ,
357- reason : 'ThrottlingException' ,
358- reasonDesc : `ThrottlingException: Maximum com.amazon.aws.codewhisperer.StartCodeAnalysis reached for this month.` ,
359- passive : false ,
360- } )
361- } )
362-
363236 it ( 'Should set monthly quota exceeded when throttled for auto file scans' , async function ( ) {
364237 getFetchStubWithResponse ( { status : 200 , statusText : 'testing stub' } )
365238 await model . CodeScansState . instance . setScansEnabled ( true )
0 commit comments