@@ -17,14 +17,7 @@ import { assertTelemetry, closeAllEditors, getFetchStubWithResponse } from '../t
1717import { AWSError } from 'aws-sdk'
1818import { getTestWindow } from '../shared/vscode/window'
1919import { SeverityLevel } from '../shared/vscode/message'
20- import { cancel } from '../../shared/localizedText'
21- import {
22- showScannedFilesMessage ,
23- stopScanMessage ,
24- CodeAnalysisScope ,
25- monthlyLimitReachedNotification ,
26- scansLimitReachedErrorMessage ,
27- } from '../../codewhisperer/models/constants'
20+ import { showScannedFilesMessage , CodeAnalysisScope } from '../../codewhisperer/models/constants'
2821import * as model from '../../codewhisperer/models/model'
2922import * as errors from '../../shared/errors'
3023import * as timeoutUtils from '../../shared/utilities/timeoutUtils'
@@ -124,70 +117,6 @@ describe('startSecurityScan', function () {
124117 } )
125118 } )
126119
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-
191120 it ( 'Should stop security scan for auto file scans if setting is disabled' , async function ( ) {
192121 getFetchStubWithResponse ( { status : 200 , statusText : 'testing stub' } )
193122 const securityScanRenderSpy = sinon . spy ( diagnosticsProvider , 'initSecurityScanRender' )
@@ -272,39 +201,6 @@ describe('startSecurityScan', function () {
272201 ] )
273202 } )
274203
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-
308204 it ( 'Should handle failed scan job status' , async function ( ) {
309205 getFetchStubWithResponse ( { status : 200 , statusText : 'testing stub' } )
310206
@@ -330,36 +226,6 @@ describe('startSecurityScan', function () {
330226 } )
331227 } )
332228
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-
363229 it ( 'Should set monthly quota exceeded when throttled for auto file scans' , async function ( ) {
364230 getFetchStubWithResponse ( { status : 200 , statusText : 'testing stub' } )
365231 await model . CodeScansState . instance . setScansEnabled ( true )
0 commit comments