Search in sources :

Example 6 with ExecutionResult

use of com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult in project sechub by mercedes-benz.

the class WithSecHubClient method startAsynchronScanFor.

public AssertAsyncResult startAsynchronScanFor(TestProject project, IntegrationTestJSONLocation location, Map<String, String> environmentVariables, ApiTokenStrategy apiTokenStrategy) {
    File sechubConfigFile = IntegrationTestFileSupport.getTestfileSupport().createFileFromResourcePath(location.getPath());
    SecHubClientExecutor executor = createExecutor();
    List<String> list = buildEnvironmentAndBehaviourCommands(project);
    ExecutionResult result = doExecute(ClientAction.START_ASYNC, apiTokenStrategy, sechubConfigFile, executor, list, environmentVariables);
    if (result.getExitCode() != 0) {
        fail("Not exit code 0 but:" + result.getExitCode() + " , last output line was:" + result.getLastOutputLine());
    }
    AssertAsyncResult asynchResult = new AssertAsyncResult();
    asynchResult.jobUUID = UUID.fromString(result.getLastOutputLine());
    asynchResult.configFile = sechubConfigFile;
    return asynchResult;
}
Also used : SecHubClientExecutor(com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor) ExecutionResult(com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult) File(java.io.File)

Example 7 with ExecutionResult

use of com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult in project sechub by mercedes-benz.

the class WithSecHubClient method unmarkAsFalsePositive.

public void unmarkAsFalsePositive(TestProject project, IntegrationTestJSONLocation location, String pathToJSONFile) {
    File sechubConfigFile = IntegrationTestFileSupport.getTestfileSupport().createFileFromResourcePath(location.getPath());
    SecHubClientExecutor executor = createExecutor();
    List<String> list = buildEnvironmentAndBehaviourCommands(project);
    list.add("-file");
    list.add(pathToJSONFile);
    ExecutionResult result = doExecute(ClientAction.UNMARK_FALSE_POSITIVES, sechubConfigFile, executor, list, null);
    if (result.getExitCode() != 0) {
        fail("Not exit code 0 but:" + result.getExitCode() + " , last output line was:" + result.getLastOutputLine());
    }
}
Also used : SecHubClientExecutor(com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor) ExecutionResult(com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult) File(java.io.File)

Example 8 with ExecutionResult

use of com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult in project sechub by mercedes-benz.

the class WithSecHubClient method markAsFalsePositive.

public void markAsFalsePositive(TestProject project, IntegrationTestJSONLocation location, String pathToJSONFile) {
    File sechubConfigFile = IntegrationTestFileSupport.getTestfileSupport().createFileFromResourcePath(location.getPath());
    SecHubClientExecutor executor = createExecutor();
    List<String> list = buildEnvironmentAndBehaviourCommands(project);
    list.add("-file");
    list.add(pathToJSONFile);
    ExecutionResult result = doExecute(ClientAction.MARK_FALSE_POSITIVES, sechubConfigFile, executor, list, null);
    if (result.getExitCode() != 0) {
        fail("Not exit code 0 but:" + result.getExitCode() + " , last output line was:" + result.getLastOutputLine());
    }
}
Also used : SecHubClientExecutor(com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor) ExecutionResult(com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult) File(java.io.File)

Example 9 with ExecutionResult

use of com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult in project sechub by mercedes-benz.

the class FalsePositivesScenario3IntTest method REST_API_direct_unmark_falsepositives_of_only_existing_medium_will_result_in_report_without_defined__And_trafficlight_changes_from_gren_to_yellow.

@Test
public void REST_API_direct_unmark_falsepositives_of_only_existing_medium_will_result_in_report_without_defined__And_trafficlight_changes_from_gren_to_yellow() throws Exception {
    /* @formatter:off */
    /**
     ********
     */
    /* prepare */
    /**
     ********
     */
    IntegrationTestJSONLocation location = IntegrationTestJSONLocation.CLIENT_JSON_SOURCESCAN_YELLOW_ZERO_WAIT;
    ExecutionResult result = as(USER_1).withSecHubClient().startSynchronScanFor(project, location);
    UUID jobUUID = result.getSechubJobUUID();
    as(USER_1).startFalsePositiveDefinition(project).add(1, jobUUID).markAsFalsePositive();
    // create scan + fetch report again (check filtering of false positive works as a precondition */
    ExecutionResult result2 = as(USER_1).withSecHubClient().startSynchronScanFor(project, location);
    assertReportUnordered(result2).finding().id(1).name("Absolute Path Traversal").isNotContained().hasTrafficLight(TrafficLight.GREEN);
    /**
     ********
     */
    /* execute */
    /**
     ********
     */
    as(USER_1).startFalsePositiveDefinition(project).add(1, jobUUID).unmarkFalsePositive();
    /**
     *****
     */
    /* test */
    /**
     *****
     */
    // create scan + fetch report again
    ExecutionResult result3 = as(USER_1).withSecHubClient().startSynchronScanFor(project, location);
    assertReportUnordered(result3).finding().id(1).name("Absolute Path Traversal").isContained().hasTrafficLight(TrafficLight.YELLOW);
/* @formatter:on */
}
Also used : IntegrationTestJSONLocation(com.mercedesbenz.sechub.integrationtest.api.IntegrationTestJSONLocation) ExecutionResult(com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult) UUID(java.util.UUID) Test(org.junit.Test)

Example 10 with ExecutionResult

use of com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult in project sechub by mercedes-benz.

the class FalsePositivesScenario3IntTest method with_sechubclient_fetch_fp_config_when_one_entry_added.

@Test
public void with_sechubclient_fetch_fp_config_when_one_entry_added() throws Exception {
    /* @formatter:off */
    /**
     ********
     */
    /* prepare */
    /**
     ********
     */
    IntegrationTestJSONLocation location = IntegrationTestJSONLocation.CLIENT_JSON_SOURCESCAN_YELLOW_ZERO_WAIT;
    ExecutionResult result = as(USER_1).withSecHubClient().startSynchronScanFor(project, location);
    assertReportUnordered(result).finding().id(1).name("Absolute Path Traversal").isContained().hasTrafficLight(TrafficLight.YELLOW);
    UUID jobUUID = result.getSechubJobUUID();
    as(USER_1).startFalsePositiveDefinition(project).add(1, jobUUID).markAsFalsePositive();
    /**
     ********
     */
    /* execute */
    /**
     ********
     */
    ProjectFalsePositivesDefinition configuration = as(USER_1).withSecHubClient().getFalsePositiveConfigurationOfProject(project, location);
    /**
     *****
     */
    /* test */
    /**
     *****
     */
    assertTrue(configuration.isContaining(1, jobUUID));
/* @formatter:on */
}
Also used : IntegrationTestJSONLocation(com.mercedesbenz.sechub.integrationtest.api.IntegrationTestJSONLocation) ExecutionResult(com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult) ProjectFalsePositivesDefinition(com.mercedesbenz.sechub.integrationtest.api.AsUser.ProjectFalsePositivesDefinition) UUID(java.util.UUID) Test(org.junit.Test)

Aggregations

ExecutionResult (com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult)31 Test (org.junit.Test)25 UUID (java.util.UUID)19 File (java.io.File)11 IntegrationTestJSONLocation (com.mercedesbenz.sechub.integrationtest.api.IntegrationTestJSONLocation)9 AssertFullScanData (com.mercedesbenz.sechub.integrationtest.api.AssertFullScanData)6 AssertExecutionResult (com.mercedesbenz.sechub.integrationtest.api.AssertExecutionResult)5 TestProject (com.mercedesbenz.sechub.integrationtest.api.TestProject)4 SecHubClientExecutor (com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor)4 AdapterMetaData (com.mercedesbenz.sechub.adapter.AdapterMetaData)3 ProjectFalsePositivesDefinition (com.mercedesbenz.sechub.integrationtest.api.AsUser.ProjectFalsePositivesDefinition)3 FullScanDataElement (com.mercedesbenz.sechub.integrationtest.api.AssertFullScanData.FullScanDataElement)3 JSonMessageHttpStatusExceptionTestValidator (com.mercedesbenz.sechub.integrationtest.api.JSonMessageHttpStatusExceptionTestValidator)1 TestUser (com.mercedesbenz.sechub.integrationtest.api.TestUser)1 WithSecHubClient (com.mercedesbenz.sechub.integrationtest.api.WithSecHubClient)1 MappingData (com.mercedesbenz.sechub.sharedkernel.mapping.MappingData)1 MappingEntry (com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry)1 HashMap (java.util.HashMap)1