diff --git a/packages/core/src/test/codewhisperer/startSecurityScan.test.ts b/packages/core/src/test/codewhisperer/startSecurityScan.test.ts index 551949aa3ab..e45bee1b7fa 100644 --- a/packages/core/src/test/codewhisperer/startSecurityScan.test.ts +++ b/packages/core/src/test/codewhisperer/startSecurityScan.test.ts @@ -17,14 +17,7 @@ import { assertTelemetry, closeAllEditors, getFetchStubWithResponse } from '../t import { AWSError } from 'aws-sdk' import { getTestWindow } from '../shared/vscode/window' import { SeverityLevel } from '../shared/vscode/message' -import { cancel } from '../../shared/localizedText' -import { - showScannedFilesMessage, - stopScanMessage, - CodeAnalysisScope, - monthlyLimitReachedNotification, - scansLimitReachedErrorMessage, -} from '../../codewhisperer/models/constants' +import { showScannedFilesMessage, CodeAnalysisScope } from '../../codewhisperer/models/constants' import * as model from '../../codewhisperer/models/model' import * as errors from '../../shared/errors' import * as timeoutUtils from '../../shared/utilities/timeoutUtils' @@ -124,70 +117,6 @@ describe('startSecurityScan', function () { }) }) - it('Should stop security scan for project scans when confirmed', async function () { - getFetchStubWithResponse({ status: 200, statusText: 'testing stub' }) - const securityScanRenderSpy = sinon.spy(diagnosticsProvider, 'initSecurityScanRender') - const securityScanStoppedErrorSpy = sinon.spy(model, 'CodeScanStoppedError') - const testWindow = getTestWindow() - testWindow.onDidShowMessage((message) => { - if (message.message === stopScanMessage) { - message.selectItem(startSecurityScan.stopScanButton) - } - }) - model.codeScanState.setToRunning() - const scanPromise = startSecurityScan.startSecurityScan( - mockSecurityPanelViewProvider, - editor, - createClient(), - extensionContext, - CodeAnalysisScope.PROJECT, - false - ) - await startSecurityScan.confirmStopSecurityScan( - model.codeScanState, - false, - CodeAnalysisScope.PROJECT, - undefined - ) - await scanPromise - assert.ok(securityScanRenderSpy.notCalled) - assert.ok(securityScanStoppedErrorSpy.calledOnce) - const warnings = testWindow.shownMessages.filter((m) => m.severity === SeverityLevel.Warning) - assert.ok(warnings.map((m) => m.message).includes(stopScanMessage)) - }) - - it('Should not stop security scan for project scans when not confirmed', async function () { - getFetchStubWithResponse({ status: 200, statusText: 'testing stub' }) - const securityScanRenderSpy = sinon.spy(diagnosticsProvider, 'initSecurityScanRender') - const securityScanStoppedErrorSpy = sinon.spy(model, 'CodeScanStoppedError') - const testWindow = getTestWindow() - testWindow.onDidShowMessage((message) => { - if (message.message === stopScanMessage) { - message.selectItem(cancel) - } - }) - model.codeScanState.setToRunning() - const scanPromise = startSecurityScan.startSecurityScan( - mockSecurityPanelViewProvider, - editor, - createClient(), - extensionContext, - CodeAnalysisScope.PROJECT, - false - ) - await startSecurityScan.confirmStopSecurityScan( - model.codeScanState, - false, - CodeAnalysisScope.PROJECT, - undefined - ) - await scanPromise - assert.ok(securityScanRenderSpy.calledOnce) - assert.ok(securityScanStoppedErrorSpy.notCalled) - const warnings = testWindow.shownMessages.filter((m) => m.severity === SeverityLevel.Warning) - assert.ok(warnings.map((m) => m.message).includes(stopScanMessage)) - }) - it('Should stop security scan for auto file scans if setting is disabled', async function () { getFetchStubWithResponse({ status: 200, statusText: 'testing stub' }) const securityScanRenderSpy = sinon.spy(diagnosticsProvider, 'initSecurityScanRender') @@ -272,39 +201,6 @@ describe('startSecurityScan', function () { ]) }) - it('Should not cancel a project scan if a file scan has started', async function () { - getFetchStubWithResponse({ status: 200, statusText: 'testing stub' }) - await model.CodeScansState.instance.setScansEnabled(true) - - const scanPromise = startSecurityScan.startSecurityScan( - mockSecurityPanelViewProvider, - editor, - createClient(), - extensionContext, - CodeAnalysisScope.PROJECT, - false - ) - await startSecurityScan.startSecurityScan( - mockSecurityPanelViewProvider, - editor, - createClient(), - extensionContext, - CodeAnalysisScope.FILE_AUTO, - false - ) - await scanPromise - assertTelemetry('codewhisperer_securityScan', [ - { - result: 'Succeeded', - codewhispererCodeScanScope: 'FILE_AUTO', - }, - { - result: 'Succeeded', - codewhispererCodeScanScope: 'PROJECT', - }, - ]) - }) - it('Should handle failed scan job status', async function () { getFetchStubWithResponse({ status: 200, statusText: 'testing stub' }) @@ -330,36 +226,6 @@ describe('startSecurityScan', function () { }) }) - it('Should show notification when throttled for project scans', async function () { - getFetchStubWithResponse({ status: 200, statusText: 'testing stub' }) - const mockClient = createClient() - mockClient.createCodeScan.throws({ - code: 'ThrottlingException', - time: new Date(), - name: 'error name', - message: scansLimitReachedErrorMessage, - } satisfies AWSError) - sinon.stub(errors, 'isAwsError').returns(true) - const testWindow = getTestWindow() - await startSecurityScan.startSecurityScan( - mockSecurityPanelViewProvider, - editor, - mockClient, - extensionContext, - CodeAnalysisScope.PROJECT, - false - ) - - assert.ok(testWindow.shownMessages.map((m) => m.message).includes(monthlyLimitReachedNotification)) - assertTelemetry('codewhisperer_securityScan', { - codewhispererCodeScanScope: 'PROJECT', - result: 'Failed', - reason: 'ThrottlingException', - reasonDesc: `ThrottlingException: Maximum com.amazon.aws.codewhisperer.StartCodeAnalysis reached for this month.`, - passive: false, - }) - }) - it('Should set monthly quota exceeded when throttled for auto file scans', async function () { getFetchStubWithResponse({ status: 200, statusText: 'testing stub' }) await model.CodeScansState.instance.setScansEnabled(true)