Search in sources :

Example 16 with DetectDockerTestRunner

use of com.synopsys.integration.detect.battery.docker.util.DetectDockerTestRunner 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);
    }
}
Also used : ReportService(com.synopsys.integration.detect.workflow.blackduck.report.service.ReportService) DockerAssertions(com.synopsys.integration.detect.battery.docker.util.DockerAssertions) DetectCommandBuilder(com.synopsys.integration.detect.battery.docker.util.DetectCommandBuilder) DetectDockerTestRunner(com.synopsys.integration.detect.battery.docker.util.DetectDockerTestRunner) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 17 with DetectDockerTestRunner

use of com.synopsys.integration.detect.battery.docker.util.DetectDockerTestRunner in project synopsys-detect by blackducksoftware.

the class RiskReportTests method anyProjectWithRiskReportResultsInBlackDuck.

// create any bom for a risk report
SharedDockerTestRunner anyProjectWithRiskReportResultsInBlackDuck(String testId, NameVersion projectNameVersion) throws IOException, IntegrationException {
    try (DetectDockerTestRunner runner = new DetectDockerTestRunner(testId, "gradle-simple:1.0.0")) {
        runner.withImageProvider(BuildDockerImageProvider.forDockerfilResourceNamed("SimpleGradle.dockerfile"));
        BlackDuckTestConnection blackDuckTestConnection = BlackDuckTestConnection.fromEnvironment();
        BlackDuckAssertions blackduckAssertions = blackDuckTestConnection.projectVersionAssertions(projectNameVersion);
        blackduckAssertions.emptyOnBlackDuck();
        DetectCommandBuilder commandBuilder = new DetectCommandBuilder().defaults().defaultDirectories(runner);
        commandBuilder.connectToBlackDuck(blackDuckTestConnection);
        commandBuilder.projectNameVersion(blackduckAssertions);
        // All that is needed for a BOM in black duck.
        commandBuilder.tools(DetectTool.DETECTOR);
        return new SharedDockerTestRunner(runner, blackDuckTestConnection, blackduckAssertions, commandBuilder);
    }
}
Also used : SharedDockerTestRunner(com.synopsys.integration.detect.battery.docker.util.SharedDockerTestRunner) DetectCommandBuilder(com.synopsys.integration.detect.battery.docker.util.DetectCommandBuilder) DetectDockerTestRunner(com.synopsys.integration.detect.battery.docker.util.DetectDockerTestRunner)

Aggregations

DetectCommandBuilder (com.synopsys.integration.detect.battery.docker.util.DetectCommandBuilder)17 DetectDockerTestRunner (com.synopsys.integration.detect.battery.docker.util.DetectDockerTestRunner)17 DockerAssertions (com.synopsys.integration.detect.battery.docker.util.DockerAssertions)15 Test (org.junit.jupiter.api.Test)15 SharedDockerTestRunner (com.synopsys.integration.detect.battery.docker.util.SharedDockerTestRunner)2 ProjectVersionWrapper (com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper)1 ReportService (com.synopsys.integration.detect.workflow.blackduck.report.service.ReportService)1 File (java.io.File)1 Disabled (org.junit.jupiter.api.Disabled)1 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)1