Search in sources :

Example 11 with DetectDockerTestRunner

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

the class ProjectInspectorTests method gradleProjectInspector.

@Test
void gradleProjectInspector() throws IOException, InterruptedException {
    try (DetectDockerTestRunner test = new DetectDockerTestRunner("detect-gradle-project-inspector", "gradle-simple:1.0.0")) {
        test.withImageProvider(BuildDockerImageProvider.forDockerfilResourceNamed("SimpleGradle.dockerfile"));
        DetectCommandBuilder commandBuilder = DetectCommandBuilder.withOfflineDefaults().defaultDirectories(test);
        commandBuilder.property(DetectProperties.DETECT_TOOLS, "DETECTOR");
        commandBuilder.property(DetectProperties.BLACKDUCK_OFFLINE_MODE, "true");
        commandBuilder.property(DetectProperties.DETECT_BUILDLESS, "true");
        commandBuilder.property(DetectProperties.DETECT_INCLUDED_DETECTOR_TYPES, DetectorType.GRADLE.toString());
        DockerAssertions dockerAssertions = test.run(commandBuilder);
        dockerAssertions.successfulDetectorType("GRADLE");
        dockerAssertions.atLeastOneBdioFile();
        dockerAssertions.logContains("Gradle Project Inspector");
    }
}
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 12 with DetectDockerTestRunner

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

the class ProjectInspectorTests method mavenProjectInspector.

@Test
void mavenProjectInspector() throws IOException, InterruptedException {
    try (DetectDockerTestRunner test = new DetectDockerTestRunner("detect-maven-project-inspector", "maven-simple:1.0.0")) {
        test.withImageProvider(BuildDockerImageProvider.forDockerfilResourceNamed("SimpleMaven.dockerfile"));
        DetectCommandBuilder commandBuilder = DetectCommandBuilder.withOfflineDefaults().defaultDirectories(test);
        commandBuilder.property(DetectProperties.DETECT_TOOLS, "DETECTOR");
        commandBuilder.property(DetectProperties.BLACKDUCK_OFFLINE_MODE, "true");
        commandBuilder.property(DetectProperties.DETECT_BUILDLESS, "true");
        commandBuilder.property(DetectProperties.DETECT_INCLUDED_DETECTOR_TYPES, DetectorType.MAVEN.toString());
        commandBuilder.property(DetectProperties.DETECT_MAVEN_BUILDLESS_LEGACY_MODE, "false");
        DockerAssertions dockerAssertions = test.run(commandBuilder);
        dockerAssertions.successfulDetectorType("MAVEN");
        dockerAssertions.atLeastOneBdioFile();
        dockerAssertions.logContains("Maven Project Inspector");
    }
}
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 13 with DetectDockerTestRunner

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

the class SbtEncodingTest method sbtEncoding.

@Test
void sbtEncoding() throws IOException {
    try (DetectDockerTestRunner test = new DetectDockerTestRunner("detect-sbt-encoding", "detect-sbt-encoding:1.0.3")) {
        test.withImageProvider(BuildDockerImageProvider.forDockerfilResourceNamed("SbtEncoding.dockerfile"));
        DetectCommandBuilder commandBuilder = DetectCommandBuilder.withOfflineDefaults().defaultDirectories(test);
        commandBuilder.tools(DetectTool.DETECTOR);
        commandBuilder.property(DetectProperties.DETECT_SBT_ARGUMENTS, "-Dsbt.log.noformat=true");
        DockerAssertions dockerAssertions = test.run(commandBuilder);
        dockerAssertions.atLeastOneBdioFile();
        dockerAssertions.projectVersion("sbt-simple-project_2.12", "1.0.0-SNAPSHOT");
    }
}
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 14 with DetectDockerTestRunner

use of com.synopsys.integration.detect.battery.docker.util.DetectDockerTestRunner 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);
    }
}
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) Disabled(org.junit.jupiter.api.Disabled)

Example 15 with DetectDockerTestRunner

use of com.synopsys.integration.detect.battery.docker.util.DetectDockerTestRunner 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());
    }
}
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) ExtendWith(org.junit.jupiter.api.extension.ExtendWith)

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