Search in sources :

Example 1 with SharedDockerTestRunner

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

the class RapidModeTests method anyProjectWithRapidResultsInBlackDuck.

SharedDockerTestRunner anyProjectWithRapidResultsInBlackDuck(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)

Example 2 with SharedDockerTestRunner

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

the class RapidModeTests method rapidModeSmokeTest.

@Test
void rapidModeSmokeTest() throws IOException, IntegrationException {
    SharedDockerTestRunner test = anyProjectWithRapidResultsInBlackDuck("rapid-mode-smoke-test", new NameVersion("rapid-mode", "smoke-test"));
    // Ensuring regardless of the source or working directory being chosen, this test still produces a risk report in the same location.
    test.command.property(DetectProperties.DETECT_BLACKDUCK_SCAN_MODE, "RAPID");
    DockerAssertions dockerAssertions = test.run();
    dockerAssertions.logContains("Critical and blocking policy violations for");
    dockerAssertions.logContains("* Components: 0");
    dockerAssertions.successfulOperation("Generate Rapid Json File");
}
Also used : SharedDockerTestRunner(com.synopsys.integration.detect.battery.docker.util.SharedDockerTestRunner) NameVersion(com.synopsys.integration.util.NameVersion) DockerAssertions(com.synopsys.integration.detect.battery.docker.util.DockerAssertions) Test(org.junit.jupiter.api.Test)

Example 3 with SharedDockerTestRunner

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

the class RiskReportTests method riskReportNotCreatedInWorkingDir.

@Test
void riskReportNotCreatedInWorkingDir() throws IOException, InterruptedException, IntegrationException {
    SharedDockerTestRunner test = anyProjectWithRiskReportResultsInBlackDuck("risk-report-does-not-use-working-directory", new NameVersion("risk-reports", "default-not-working-directory"));
    test.runner.withWorkingDirectory("/opt/random");
    test.command.property(DetectProperties.DETECT_SOURCE_PATH, "/opt/project/src");
    test.command.property(DetectProperties.DETECT_RISK_REPORT_PDF, "true");
    DockerAssertions dockerAssertions = test.run();
    dockerAssertions.resultProducedAtLocation("/opt/project/src/risk_reports_default_not_working_directory_BlackDuck_RiskReport.pdf");
}
Also used : SharedDockerTestRunner(com.synopsys.integration.detect.battery.docker.util.SharedDockerTestRunner) NameVersion(com.synopsys.integration.util.NameVersion) DockerAssertions(com.synopsys.integration.detect.battery.docker.util.DockerAssertions) Test(org.junit.jupiter.api.Test)

Example 4 with SharedDockerTestRunner

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

the class RiskReportTests method riskReportSmokeTest.

@Test
void riskReportSmokeTest() throws IOException, InterruptedException, IntegrationException {
    SharedDockerTestRunner test = anyProjectWithRiskReportResultsInBlackDuck("risk-report-smoke-test", new NameVersion("risk-reports", "smoke-test"));
    // Ensuring regardless of the source or working directory being chosen, this test still produces a risk report in the same location.
    test.runner.withWorkingDirectory("/opt/project/src");
    test.command.property(DetectProperties.DETECT_SOURCE_PATH, "/opt/project/src");
    test.command.property(DetectProperties.DETECT_RISK_REPORT_PDF, "true");
    DockerAssertions dockerAssertions = test.run();
    dockerAssertions.resultProducedAtLocation("/opt/project/src/risk_reports_smoke_test_BlackDuck_RiskReport.pdf");
}
Also used : SharedDockerTestRunner(com.synopsys.integration.detect.battery.docker.util.SharedDockerTestRunner) NameVersion(com.synopsys.integration.util.NameVersion) DockerAssertions(com.synopsys.integration.detect.battery.docker.util.DockerAssertions) Test(org.junit.jupiter.api.Test)

Example 5 with SharedDockerTestRunner

use of com.synopsys.integration.detect.battery.docker.util.SharedDockerTestRunner 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

SharedDockerTestRunner (com.synopsys.integration.detect.battery.docker.util.SharedDockerTestRunner)6 DockerAssertions (com.synopsys.integration.detect.battery.docker.util.DockerAssertions)4 NameVersion (com.synopsys.integration.util.NameVersion)4 Test (org.junit.jupiter.api.Test)4 DetectCommandBuilder (com.synopsys.integration.detect.battery.docker.util.DetectCommandBuilder)2 DetectDockerTestRunner (com.synopsys.integration.detect.battery.docker.util.DetectDockerTestRunner)2