From e0953ef2468377eae2e6036602e6e2e6af71b5e8 Mon Sep 17 00:00:00 2001 From: Or Geva Date: Fri, 3 Nov 2023 07:56:15 +0200 Subject: [PATCH] Add integration test --- .../externalResourcesRepository.test.ts | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/test/tests/integration/externalResourcesRepository.test.ts diff --git a/src/test/tests/integration/externalResourcesRepository.test.ts b/src/test/tests/integration/externalResourcesRepository.test.ts new file mode 100644 index 00000000..b2f2908b --- /dev/null +++ b/src/test/tests/integration/externalResourcesRepository.test.ts @@ -0,0 +1,41 @@ +import { assert } from 'chai'; +import * as fs from 'fs'; +import * as path from 'path'; + +import { AnalyzeScanRequest } from '../../../main/scanLogic/scanRunners/analyzerModels'; +import { SecretsRunner, SecretsScanResponse } from '../../../main/scanLogic/scanRunners/secretsScan'; +import { + AnalyzerManagerIntegrationEnv, +} from '../utils/testIntegration.test'; +import { Configuration } from '../../../main/utils/configuration'; + +describe.only('External Resources Repository Integration Tests', async () => { + const integrationManager: AnalyzerManagerIntegrationEnv = new AnalyzerManagerIntegrationEnv(); + const testDataRoot: string = path.join(__dirname, '..', '..', 'resources', 'secretsScan'); + + let runner: SecretsRunner; + let response: SecretsScanResponse; + let expectedContent: SecretsScanResponse; + + before(async function () { + process.env[Configuration.JFROG_IDE_RELEASES_REPO] = 'releases-proxy'; + + // Integration initialization + await integrationManager.initialize(testDataRoot); + runner = integrationManager.entitledJasRunnerFactory.createSecretsRunners()[0]; + + // Get expected partial result that the scan should contain + let dataPath: string = path.join(testDataRoot, 'expectedScanResponse.json'); + expectedContent = JSON.parse(fs.readFileSync(dataPath, 'utf8').toString()); + assert.isDefined(expectedContent, 'Failed to read expected SecretsScanResponse content from ' + dataPath); + response = await runner + .executeRequest(() => undefined, { roots: [testDataRoot] } as AnalyzeScanRequest) + .then(runResult => runner.convertResponse(runResult)); + }); + after(() => { + delete process.env[Configuration.JFROG_IDE_RELEASES_REPO]; + }); + it('Check response defined', () => { + assert.isDefined(response); + }); +});