forked from jfrog/jfrog-vscode-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
39 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 36 additions & 18 deletions
54
src/test/tests/integration/externalResourcesRepository.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,59 @@ | ||
import { assert } from 'chai'; | ||
import * as fs from 'fs'; | ||
import fs from 'fs-extra'; | ||
|
||
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'; | ||
import { AnalyzerManager } from '../../../main/scanLogic/scanRunners/analyzerManager'; | ||
|
||
describe.only('External Resources Repository Integration Tests', async () => { | ||
describe('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 () { | ||
fs.removeSync(path.dirname(AnalyzerManager.ANALYZER_MANAGER_PATH)); | ||
}); | ||
|
||
before(async function() { | ||
process.env[Configuration.JFROG_IDE_RELEASES_REPO_ENV] = 'releases-proxy'; | ||
after(() => { | ||
delete process.env[Configuration.JFROG_IDE_RELEASES_REPO_ENV]; | ||
}); | ||
|
||
// Integration initialization | ||
it('Should fail to download the analyzer manager from none existing repository', async () => { | ||
process.env[Configuration.JFROG_IDE_RELEASES_REPO_ENV] = 'none-existing-releases-proxy'; | ||
// Prepare | ||
await integrationManager.initialize(testDataRoot); | ||
runner = integrationManager.entitledJasRunnerFactory.createSecretsRunners()[0]; | ||
|
||
// Get expected partial result that the scan should contain | ||
const runner: SecretsRunner = integrationManager.entitledJasRunnerFactory.createSecretsRunners()[0]; | ||
let dataPath: string = path.join(testDataRoot, 'expectedScanResponse.json'); | ||
expectedContent = JSON.parse(fs.readFileSync(dataPath, 'utf8').toString()); | ||
const expectedContent: any = JSON.parse(fs.readFileSync(dataPath, 'utf8').toString()); | ||
assert.isDefined(expectedContent, 'Failed to read expected SecretsScanResponse content from ' + dataPath); | ||
response = await runner | ||
|
||
// Run | ||
const response: SecretsScanResponse = await runner | ||
.executeRequest(() => undefined, { roots: [testDataRoot] } as AnalyzeScanRequest) | ||
.then(runResult => runner.convertResponse(runResult)); | ||
}); | ||
|
||
after(() => { | ||
delete process.env[Configuration.JFROG_IDE_RELEASES_REPO_ENV]; | ||
// Assert | ||
assert.isUndefined(response.filesWithIssues); | ||
}); | ||
|
||
it('Check response defined', () => { | ||
assert.isDefined(response); | ||
it('Should download the analyzer manager from releases-proxy instead of direct releases.jfrog.io', async () => { | ||
process.env[Configuration.JFROG_IDE_RELEASES_REPO_ENV] = 'releases-proxy'; | ||
// Prepare | ||
await integrationManager.initialize(testDataRoot); | ||
const runner: SecretsRunner = integrationManager.entitledJasRunnerFactory.createSecretsRunners()[0]; | ||
let dataPath: string = path.join(testDataRoot, 'expectedScanResponse.json'); | ||
const expectedContent: any = JSON.parse(fs.readFileSync(dataPath, 'utf8').toString()); | ||
assert.isDefined(expectedContent, 'Failed to read expected SecretsScanResponse content from ' + dataPath); | ||
|
||
// Run | ||
const response: SecretsScanResponse = await runner | ||
.executeRequest(() => undefined, { roots: [testDataRoot] } as AnalyzeScanRequest) | ||
.then(runResult => runner.convertResponse(runResult)); | ||
|
||
// Assert | ||
assert.isDefined(response.filesWithIssues); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters