Search in sources :

Example 1 with DockerAssertions

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

the class DetectOnDetectTest method detectOnDetect.

@Test
void detectOnDetect() throws IOException, IntegrationException {
    try (DetectDockerTestRunner test = new DetectDockerTestRunner("detect-on-detect", "detect-7.1.0:1.0.0")) {
        test.withImageProvider(BuildDockerImageProvider.forDockerfilResourceNamed("Detect-7.1.0.dockerfile"));
        BlackDuckTestConnection blackDuckTestConnection = BlackDuckTestConnection.fromEnvironment();
        BlackDuckAssertions blackduckAssertions = blackDuckTestConnection.projectVersionAssertions("detect-on-detect-docker", "happy-path");
        blackduckAssertions.emptyOnBlackDuck();
        DetectCommandBuilder commandBuilder = new DetectCommandBuilder().defaults().defaultDirectories(test);
        commandBuilder.connectToBlackDuck(blackDuckTestConnection);
        commandBuilder.projectNameVersion(blackduckAssertions);
        commandBuilder.waitForResults();
        DockerAssertions dockerAssertions = test.run(commandBuilder);
        // 7 code locations, 6 bdio, 1 signature scanner
        dockerAssertions.bdioFiles(1);
        blackduckAssertions.hasCodeLocations("src/detect-on-detect-docker/happy-path scan");
        blackduckAssertions.hasComponents("jackson-core");
    }
}
Also used : 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) Test(org.junit.jupiter.api.Test)

Example 2 with DockerAssertions

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

the class DetectOnDetectTest method riskReportResultProduced.

@Test
public // Simply verify a risk report is generated at the expected location.
void riskReportResultProduced() throws Exception {
    try (DetectDockerTestRunner test = new DetectDockerTestRunner("detect-on-detect-riskreport-default", "detect-7.1.0:1.0.0")) {
        test.withImageProvider(BuildDockerImageProvider.forDockerfilResourceNamed("Detect-7.1.0.dockerfile"));
        BlackDuckTestConnection blackDuckTestConnection = BlackDuckTestConnection.fromEnvironment();
        BlackDuckAssertions blackDuckAssertions = blackDuckTestConnection.projectVersionAssertions("synopsys-detect-junit", "risk-report-default");
        blackDuckAssertions.emptyOnBlackDuck();
        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.tools(DetectTool.DETECTOR);
        DockerAssertions dockerAssertions = test.run(commandBuilder);
        dockerAssertions.resultProducedAtLocation("/opt/project/src/synopsys_detect_junit_risk_report_default_BlackDuck_RiskReport.pdf");
    }
}
Also used : 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) Test(org.junit.jupiter.api.Test)

Example 3 with DockerAssertions

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

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

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

Aggregations

DockerAssertions (com.synopsys.integration.detect.battery.docker.util.DockerAssertions)19 Test (org.junit.jupiter.api.Test)19 DetectCommandBuilder (com.synopsys.integration.detect.battery.docker.util.DetectCommandBuilder)15 DetectDockerTestRunner (com.synopsys.integration.detect.battery.docker.util.DetectDockerTestRunner)15 SharedDockerTestRunner (com.synopsys.integration.detect.battery.docker.util.SharedDockerTestRunner)4 NameVersion (com.synopsys.integration.util.NameVersion)4 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