2020-12-09 15:10:12 +00:00
|
|
|
import {
|
|
|
|
REPORT_TYPE_SAST,
|
|
|
|
REPORT_TYPE_SECRET_DETECTION,
|
2021-01-04 09:10:04 +00:00
|
|
|
REPORT_FILE_TYPES,
|
2020-12-09 15:10:12 +00:00
|
|
|
} from '~/vue_shared/security_reports/constants';
|
2021-02-14 18:09:20 +00:00
|
|
|
import { extractSecurityReportArtifacts } from '~/vue_shared/security_reports/utils';
|
2020-12-09 15:10:12 +00:00
|
|
|
import {
|
|
|
|
securityReportDownloadPathsQueryResponse,
|
|
|
|
sastArtifacts,
|
|
|
|
secretDetectionArtifacts,
|
2021-01-04 09:10:04 +00:00
|
|
|
archiveArtifacts,
|
|
|
|
traceArtifacts,
|
|
|
|
metadataArtifacts,
|
2020-12-09 15:10:12 +00:00
|
|
|
} from './mock_data';
|
|
|
|
|
|
|
|
describe('extractSecurityReportArtifacts', () => {
|
|
|
|
it.each`
|
|
|
|
reportTypes | expectedArtifacts
|
|
|
|
${[]} | ${[]}
|
|
|
|
${['foo']} | ${[]}
|
|
|
|
${[REPORT_TYPE_SAST]} | ${sastArtifacts}
|
|
|
|
${[REPORT_TYPE_SECRET_DETECTION]} | ${secretDetectionArtifacts}
|
|
|
|
${[REPORT_TYPE_SAST, REPORT_TYPE_SECRET_DETECTION]} | ${[...secretDetectionArtifacts, ...sastArtifacts]}
|
2021-01-04 09:10:04 +00:00
|
|
|
${[REPORT_FILE_TYPES.ARCHIVE]} | ${archiveArtifacts}
|
|
|
|
${[REPORT_FILE_TYPES.TRACE]} | ${traceArtifacts}
|
|
|
|
${[REPORT_FILE_TYPES.METADATA]} | ${metadataArtifacts}
|
2020-12-09 15:10:12 +00:00
|
|
|
`(
|
|
|
|
'returns the expected artifacts given report types $reportTypes',
|
|
|
|
({ reportTypes, expectedArtifacts }) => {
|
|
|
|
expect(
|
|
|
|
extractSecurityReportArtifacts(reportTypes, securityReportDownloadPathsQueryResponse),
|
|
|
|
).toEqual(expectedArtifacts);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|