use of com.synopsys.integration.detect.battery.docker.util.DockerAssertions in project synopsys-detect by blackducksoftware.
the class DetectOnAlertTest method detectOnAlert.
@Test
@Disabled
// currently adds a lot of time, for I expect little value. If useful, feel free to re-enable.
void detectOnAlert() throws IOException, IntegrationException {
try (DetectDockerTestRunner test = new DetectDockerTestRunner("detect-on-alert", "alert-6.5.0:1.0.1")) {
test.withImageProvider(BuildDockerImageProvider.forDockerfilResourceNamed("Alert-6.5.0.dockerfile"));
BlackDuckTestConnection blackDuckTestConnection = BlackDuckTestConnection.fromEnvironment();
BlackDuckAssertions blackduckAssertions = blackDuckTestConnection.projectVersionAssertions("blackduck-alert", "6.5.1-SNAPSHOT");
blackduckAssertions.emptyOnBlackDuck();
DetectCommandBuilder commandBuilder = new DetectCommandBuilder().defaults().defaultDirectories(test);
commandBuilder.connectToBlackDuck(blackDuckTestConnection);
commandBuilder.waitForResults();
DockerAssertions dockerAssertions = test.run(commandBuilder);
dockerAssertions.projectVersion(blackduckAssertions.getProjectNameVersion());
blackduckAssertions.codeLocationCount(16);
}
}
use of com.synopsys.integration.detect.battery.docker.util.DockerAssertions in project synopsys-detect by blackducksoftware.
the class DetectOnDetectTest method testDryRunScanWithSnippetMatching.
@Test
@ExtendWith(TempDirectory.class)
public void testDryRunScanWithSnippetMatching(@TempDirectory.TempDir Path tempOutputDirectory) throws Exception {
try (DetectDockerTestRunner test = new DetectDockerTestRunner("detect-on-detect-dryrun", "detect-7.1.0:1.0.0")) {
test.withImageProvider(BuildDockerImageProvider.forDockerfilResourceNamed("Detect-7.1.0.dockerfile"));
String projectName = "synopsys-detect-junit";
String projectVersionName = "dryrun-scan";
BlackDuckTestConnection blackDuckTestConnection = BlackDuckTestConnection.fromEnvironment();
BlackDuckAssertions blackDuckAssertions = blackDuckTestConnection.projectVersionAssertions(projectName, projectVersionName);
blackDuckAssertions.emptyOnBlackDuck();
DetectCommandBuilder commandBuilder = new DetectCommandBuilder().defaults().defaultDirectories(test);
commandBuilder.projectNameVersion(blackDuckAssertions.getProjectNameVersion());
commandBuilder.connectToBlackDuck(blackDuckTestConnection);
commandBuilder.property(DetectProperties.DETECT_BLACKDUCK_SIGNATURE_SCANNER_SNIPPET_MATCHING, "SNIPPET_MATCHING");
commandBuilder.property(DetectProperties.DETECT_BLACKDUCK_SIGNATURE_SCANNER_DRY_RUN, "true");
DockerAssertions dockerAssertions = test.run(commandBuilder);
assertDirectoryStructureForOfflineScan(dockerAssertions.getOutputDirectory().toPath());
}
}
use of com.synopsys.integration.detect.battery.docker.util.DockerAssertions in project synopsys-detect by blackducksoftware.
the class DetectOnDetectTest method riskReportPopulatedAtCustomPath.
@Test
public // Tests that a new project has an empty report, run detect to fill it, tests the report is filled, in a custom location
void riskReportPopulatedAtCustomPath() throws Exception {
try (DetectDockerTestRunner test = new DetectDockerTestRunner("detect-on-detect-riskreport-custom", "detect-7.1.0:1.0.0")) {
test.withImageProvider(BuildDockerImageProvider.forDockerfilResourceNamed("Detect-7.1.0.dockerfile"));
BlackDuckTestConnection blackDuckTestConnection = BlackDuckTestConnection.fromEnvironment();
ReportService reportService = blackDuckTestConnection.createReportService();
BlackDuckAssertions blackDuckAssertions = blackDuckTestConnection.projectVersionAssertions("synopsys-detect-junit", "risk-report-custom");
ProjectVersionWrapper projectVersionWrapper = blackDuckAssertions.emptyOnBlackDuck();
String reportDirectoryImagePath = "/opt/report";
File reportDirectory = test.directories().createResultDirectory("report");
test.directories().withBinding(reportDirectory, reportDirectoryImagePath);
long initialFileLength = assertEmptyRiskReport(reportDirectory, projectVersionWrapper, reportService);
DetectCommandBuilder commandBuilder = new DetectCommandBuilder().defaults().defaultDirectories(test);
commandBuilder.connectToBlackDuck(blackDuckTestConnection);
commandBuilder.projectNameVersion(blackDuckAssertions.getProjectNameVersion());
commandBuilder.property(DetectProperties.DETECT_RISK_REPORT_PDF, "true");
commandBuilder.property(DetectProperties.DETECT_TIMEOUT, "1200");
commandBuilder.property(DetectProperties.DETECT_RISK_REPORT_PDF_PATH, reportDirectoryImagePath);
commandBuilder.tools(DetectTool.DETECTOR);
DockerAssertions dockerAssertions = test.run(commandBuilder);
dockerAssertions.resultProducedAtLocation("/opt/report/synopsys_detect_junit_risk_report_custom_BlackDuck_RiskReport.pdf");
List<File> pdfFiles = getPdfFiles(reportDirectory);
assertEquals(1, pdfFiles.size());
long postLength = pdfFiles.get(0).length();
assertTrue(postLength > initialFileLength);
}
}
use of com.synopsys.integration.detect.battery.docker.util.DockerAssertions in project synopsys-detect by blackducksoftware.
the class RiskReportTests method riskReportCreatedInCustomDirectoryEvenIfItDoesntExist.
@Test
void riskReportCreatedInCustomDirectoryEvenIfItDoesntExist() throws IOException, InterruptedException, IntegrationException {
SharedDockerTestRunner test = anyProjectWithRiskReportResultsInBlackDuck("risk-report-directory-does-not-exist", new NameVersion("risk-reports", "directory-does-not-exist"));
test.command.property(DetectProperties.DETECT_RISK_REPORT_PDF, "true");
// simply using a directory that does not exist
test.command.property(DetectProperties.DETECT_RISK_REPORT_PDF_PATH, "/opt/report/");
DockerAssertions dockerAssertions = test.run();
dockerAssertions.resultProducedAtLocation("/opt/report/risk_reports_directory_does_not_exist_BlackDuck_RiskReport.pdf");
}
Aggregations