Search in sources :

Example 16 with ExecutionResult

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

the class TriggerNewInfraScanJobScenario3User1Action method executeImplAfterRestHelperSwitched.

@Override
protected void executeImplAfterRestHelperSwitched(ActionEvent e) {
    ExecutionResult result = TestAPI.as(Scenario3.USER_1).withSecHubClient().createInfraScanAndFetchScanData(Scenario3.PROJECT_1);
    outputAsTextOnSuccess("Job executed, data fetched, last output line:" + result.getLastOutputLine());
    outputAsTextOnSuccess("Job UID was:" + result.getSechubJobUUID());
}
Also used : ExecutionResult(com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult)

Example 17 with ExecutionResult

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

the class TriggerSecHubClientSynchronousScanAction method execute.

@Override
public void execute(ActionEvent event) throws Exception {
    /* @formatter:off */
    Optional<String> optionalProject = getUserInput("Please enter project id (or cancel to leave empty)", InputCacheIdentifier.PROJECT_ID);
    Optional<String> optionalPath = getUserInput("Please enter target folder for sechub scan:\n\n" + (optionalProject.isPresent() ? "" : "WARN: You didn't define a project. So this folder must contain a sechub.json having projectId defined inside to work!)") + "\nServer, user and apitoken are used by DAUI setup!\n" + "INFO: You can set a a default by system property:\n" + ConfigurationSetup.SECHUB_TARGETFOLDER_FOR_SECHUB_CLIENT_SCAN.getSystemPropertyid(), InputCacheIdentifier.CLIENT_SCAN_TARGETFOLDER);
    /* @formatter:on */
    if (!optionalPath.isPresent()) {
        return;
    }
    String path = optionalPath.get();
    File file = new File(path);
    if (!file.exists()) {
        warn("File:" + file.getAbsolutePath() + " does not exist!");
        return;
    }
    WithSecHubClient withClient = getContext().getAdministration().withSecHubClientOnDefinedBinPath();
    Map<String, String> environmentVariables = new HashMap<>();
    ExecutionResult result = withClient.startSynchronScanFor(optionalProject.isPresent() ? new TestProject(optionalProject.get()) : null, environmentVariables, file, ApiTokenStrategy.HIDEN_BY_ENV, ClientWaitMode.WAIT_WITH_ENV_SETTINGS);
    output("synchronous scan done");
    output("RESULT:");
    output("- exitcode:" + result.getExitCode());
    output("- sechub job UUID:" + result.getSechubJobUUID());
    output("- traffic light:" + result.getTrafficLight());
    output("- last outputline:" + result.getLastOutputLine());
    output("- report file location:" + result.getJSONReportFile());
}
Also used : TestProject(com.mercedesbenz.sechub.integrationtest.api.TestProject) HashMap(java.util.HashMap) ExecutionResult(com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult) File(java.io.File) WithSecHubClient(com.mercedesbenz.sechub.integrationtest.api.WithSecHubClient)

Example 18 with ExecutionResult

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

the class ProductExecutorConfigurationScenario8IntTest method one_profile_with_two_configs_for_same_product_result_in_scanlog_with_separated_metadata_and_result_entries.

@Test
public void one_profile_with_two_configs_for_same_product_result_in_scanlog_with_separated_metadata_and_result_entries() {
    /* prepare */
    // info: we use NETSPARKER here, because our standard results for a web scan in
    // mocked
    // product results for web scans is currently always NETSPARKER
    UUID config1UUID = createExecutorConfig(TestExecutorProductIdentifier.NETSPARKER, "exec-config-1");
    UUID config2UUID = createExecutorConfig(TestExecutorProductIdentifier.NETSPARKER, "exec-config-2");
    String profileId = "profile1";
    createOrResetProfile(profileId);
    /* @formatter:off */
    as(SUPER_ADMIN).addConfigurationToProfile(profileId, config1UUID, config2UUID).addProjectsToProfile(profileId, PROJECT_1);
    /* execute */
    ExecutionResult result = as(USER_1).createWebScanAndFetchScanData(PROJECT_1);
    /* test */
    File zipfile = as(SUPER_ADMIN).downloadFullScanDataFor(result.getSechubJobUUID());
    AssertFullScanData assertFullScanDataZipFile = assertFullScanDataZipFile(zipfile);
    assertFullScanDataZipFile.dumpDownloadFilePath().containsFile(// fallback means no config, so no postfix
    "SERECO.json").containsFile(// fallback means no config, so no postfix
    "metadata_SERECO.json").containsFile("NETSPARKER_" + config1UUID + ".xml").containsFile("metadata_NETSPARKER_" + config1UUID + ".json").containsFile("NETSPARKER_" + config2UUID + ".xml").containsFile("metadata_NETSPARKER_" + config2UUID + ".json").containsFileStartingWith("log_").containsFiles(7);
    AdapterMetaData metaData1 = assertFullScanDataZipFile.resolveFile("metadata_NETSPARKER_" + config1UUID + ".json").asAdapterMetaData();
    assertEquals("+1+1", metaData1.getValue(AbstractMockedAdapter.KEY_METADATA_REUSED));
    AdapterMetaData metaData2 = assertFullScanDataZipFile.resolveFile("metadata_NETSPARKER_" + config2UUID + ".json").asAdapterMetaData();
    assertEquals("+1+1", metaData2.getValue(AbstractMockedAdapter.KEY_METADATA_REUSED));
/* @formatter:on */
}
Also used : AssertFullScanData(com.mercedesbenz.sechub.integrationtest.api.AssertFullScanData) ExecutionResult(com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult) UUID(java.util.UUID) File(java.io.File) AdapterMetaData(com.mercedesbenz.sechub.adapter.AdapterMetaData) Test(org.junit.Test)

Example 19 with ExecutionResult

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

the class ProductExecutorConfigurationScenario8IntTest method two_profiles_with_two_configs_for_same_product_result_in_scanlog_with_separeted_metadata_and_result_entries.

@Test
public void two_profiles_with_two_configs_for_same_product_result_in_scanlog_with_separeted_metadata_and_result_entries() {
    /* prepare */
    // info: we use NETSPARKER here, because our standard results for a web scan in
    // mocked
    // product results for web scans is currently always NETSPARKER
    UUID config1UUID = createExecutorConfig(TestExecutorProductIdentifier.NETSPARKER, "exec-config-1");
    UUID config2UUID = createExecutorConfig(TestExecutorProductIdentifier.NETSPARKER, "exec-config-2");
    String profileId1 = "profile1";
    createOrResetProfile(profileId1);
    /* @formatter:off */
    as(SUPER_ADMIN).addConfigurationToProfile(profileId1, config1UUID).addProjectsToProfile(profileId1, PROJECT_1);
    String profileId2 = "profile2";
    createOrResetProfile(profileId2);
    as(SUPER_ADMIN).addConfigurationToProfile(profileId1, config2UUID).addProjectsToProfile(profileId1, PROJECT_1);
    /* execute */
    ExecutionResult result = as(USER_1).createWebScanAndFetchScanData(PROJECT_1);
    /* test */
    File zipfile = as(SUPER_ADMIN).downloadFullScanDataFor(result.getSechubJobUUID());
    AssertFullScanData assertFullScanDataZipFile = assertFullScanDataZipFile(zipfile);
    assertFullScanDataZipFile.dumpDownloadFilePath().containsFile(// fallback means no config, so no postfix
    "SERECO.json").containsFile(// fallback means no config, so no postfix
    "metadata_SERECO.json").containsFile("NETSPARKER_" + config1UUID + ".xml").containsFile("metadata_NETSPARKER_" + config1UUID + ".json").containsFile("NETSPARKER_" + config2UUID + ".xml").containsFile("metadata_NETSPARKER_" + config2UUID + ".json").containsFileStartingWith("log_").containsFiles(7);
    /* check adapter persistence of reused meta data not more than two times called */
    AdapterMetaData metaData1 = assertFullScanDataZipFile.resolveFile("metadata_NETSPARKER_" + config1UUID + ".json").asAdapterMetaData();
    assertEquals("+1+1", metaData1.getValue(AbstractMockedAdapter.KEY_METADATA_REUSED));
    AdapterMetaData metaData2 = assertFullScanDataZipFile.resolveFile("metadata_NETSPARKER_" + config2UUID + ".json").asAdapterMetaData();
    assertEquals("+1+1", metaData2.getValue(AbstractMockedAdapter.KEY_METADATA_REUSED));
/* @formatter:on */
}
Also used : AssertFullScanData(com.mercedesbenz.sechub.integrationtest.api.AssertFullScanData) ExecutionResult(com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult) UUID(java.util.UUID) File(java.io.File) AdapterMetaData(com.mercedesbenz.sechub.adapter.AdapterMetaData) Test(org.junit.Test)

Example 20 with ExecutionResult

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

the class ProductExecutorConfigurationScenario8IntTest method two_profiles_with_same_config_inside_for_same_product_result_in_scanlog_with_one_metadata_and_result_entry_for_product.

@Test
public void two_profiles_with_same_config_inside_for_same_product_result_in_scanlog_with_one_metadata_and_result_entry_for_product() {
    /* prepare */
    // info: we use NETSPARKER here, because our standard results for a web scan in
    // mocked
    // product results for web scans is currently always NETSPARKER
    UUID config1UUID = createExecutorConfig(TestExecutorProductIdentifier.NETSPARKER, "exec-config-1");
    /* @formatter:off */
    String profileId1 = "profile1";
    createOrResetProfile(profileId1);
    as(SUPER_ADMIN).addConfigurationToProfile(profileId1, config1UUID).addProjectsToProfile(profileId1, PROJECT_1);
    String profileId2 = "profile2";
    createOrResetProfile(profileId2);
    as(SUPER_ADMIN).addConfigurationToProfile(profileId2, config1UUID).addProjectsToProfile(profileId2, PROJECT_1);
    /* execute */
    ExecutionResult result = as(USER_1).createWebScanAndFetchScanData(PROJECT_1);
    /* test */
    File zipfile = as(SUPER_ADMIN).downloadFullScanDataFor(result.getSechubJobUUID());
    AssertFullScanData assertFullScanDataZipFile = assertFullScanDataZipFile(zipfile);
    assertFullScanDataZipFile.dumpDownloadFilePath().containsFile(// fallback means no config, so no postfix
    "SERECO.json").containsFile(// fallback means no config, so no postfix
    "metadata_SERECO.json").containsFile("NETSPARKER_" + config1UUID + ".xml").containsFile("metadata_NETSPARKER_" + config1UUID + ".json").containsFileStartingWith("log_").containsFiles(5);
    /* check adapter persistence of reused meta data not more than two times called */
    AdapterMetaData metaData = assertFullScanDataZipFile.resolveFile("metadata_NETSPARKER_" + config1UUID + ".json").asAdapterMetaData();
    assertEquals("+1+1", metaData.getValue(AbstractMockedAdapter.KEY_METADATA_REUSED));
/* @formatter:on */
}
Also used : AssertFullScanData(com.mercedesbenz.sechub.integrationtest.api.AssertFullScanData) ExecutionResult(com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult) UUID(java.util.UUID) File(java.io.File) AdapterMetaData(com.mercedesbenz.sechub.adapter.AdapterMetaData) 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