Search in sources :

Example 21 with AdapterMetaData

use of com.mercedesbenz.sechub.adapter.AdapterMetaData in project sechub by mercedes-benz.

the class RestartJobScenario4IntTest method restart__simulate_jvm_crash_long_running_job.

@Test
public /**
 * We simulate a JVM crash where a product result was already written to
 * database.
 */
void restart__simulate_jvm_crash_long_running_job() {
    /* @formatter:off */
    /* prepare */
    clearMetaDataInspection();
    UUID sechubJobUUID = as(USER_1).triggerAsyncCodeScanWithPseudoZipUpload(project, IntegrationTestMockMode.CODE_SCAN__CHECKMARX__GREEN__4_SECONDS_WAITING);
    waitForJobRunning(project, sechubJobUUID);
    // let the old job run (so not accidently running at same time)
    waitMilliSeconds(1000);
    /* execute */
    as(SUPER_ADMIN).restartCodeScanAndFetchJobStatus(project, sechubJobUUID);
    /* test */
    String report = as(USER_1).getJobReport(project.getProjectId(), sechubJobUUID);
    assertNotNull(report);
    if (!report.contains("GREEN")) {
        assertEquals("GREEN was not found, but expected...", "GREEN", report);
    }
    /* @formatter:on */
    assertMetaDataInspections().hasAmountOfInspections(2);
    File file = as(SUPER_ADMIN).downloadFullScanDataFor(sechubJobUUID);
    UUID uuid = IntegrationTestDefaultExecutorConfigurations.CHECKMARX_V1.uuid;
    String metaDataFileName = "metadata_CHECKMARX_" + uuid + ".json";
    AssertFullScanData assertFullScanDataZipFile = assertFullScanDataZipFile(file);
    assertFullScanDataZipFile.dumpDownloadFilePath().containsFile("CHECKMARX_" + uuid + ".xml").containsFile(metaDataFileName).containsFile("SERECO.json").containsFile("metadata_SERECO.json").containsFiles(// 4 + 2 log files, no duplicates of product results!!
    6);
    /*
         * check adapter persistence of reused meta data update has been called 4 times
         * (because we have a re-run and every run does adds 2 "+1" to the value
         */
    AdapterMetaData metaData1 = assertFullScanDataZipFile.resolveFile(metaDataFileName).asAdapterMetaData();
    assertEquals("+1+1+1+1", metaData1.getValue(AbstractMockedAdapter.KEY_METADATA_REUSED));
}
Also used : AssertFullScanData(com.mercedesbenz.sechub.integrationtest.api.AssertFullScanData) UUID(java.util.UUID) File(java.io.File) AdapterMetaData(com.mercedesbenz.sechub.adapter.AdapterMetaData) Test(org.junit.Test)

Example 22 with AdapterMetaData

use of com.mercedesbenz.sechub.adapter.AdapterMetaData 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 23 with AdapterMetaData

use of com.mercedesbenz.sechub.adapter.AdapterMetaData 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 24 with AdapterMetaData

use of com.mercedesbenz.sechub.adapter.AdapterMetaData 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)

Example 25 with AdapterMetaData

use of com.mercedesbenz.sechub.adapter.AdapterMetaData in project sechub by mercedes-benz.

the class AbstractMockedAdapter method writeBeforeWaitAndReusedMetaData.

protected void writeBeforeWaitAndReusedMetaData(C config, AdapterRuntimeContext runtimeContext) {
    AdapterMetaData metaData = assertMetaData(runtimeContext);
    metaData.setValue(KEY_METADATA_BEFORE_WAIT, DEFAULT_METADATA_MOCK_BEFORE_WAIT);
    String value = metaData.getValue(KEY_METADATA_COMBINED);
    metaData.setValue(KEY_METADATA_COMBINED, value + "+2");
    updateReusedEntryAndPersistMetaData(metaData, runtimeContext);
}
Also used : AdapterMetaData(com.mercedesbenz.sechub.adapter.AdapterMetaData)

Aggregations

AdapterMetaData (com.mercedesbenz.sechub.adapter.AdapterMetaData)26 Test (org.junit.Test)10 UUID (java.util.UUID)8 File (java.io.File)5 AssertFullScanData (com.mercedesbenz.sechub.integrationtest.api.AssertFullScanData)4 CheckmarxAdapterConfig (com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxAdapterConfig)3 ProductResult (com.mercedesbenz.sechub.domain.scan.product.ProductResult)3 ExecutionResult (com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult)3 MetaDataInspection (com.mercedesbenz.sechub.sharedkernel.metadata.MetaDataInspection)3 JobStorage (com.mercedesbenz.sechub.storage.core.JobStorage)3 InputStream (java.io.InputStream)3 HttpEntity (org.springframework.http.HttpEntity)3 AdapterMetaDataCallback (com.mercedesbenz.sechub.adapter.AdapterMetaDataCallback)2 TreeMap (java.util.TreeMap)2 HttpHeaders (org.springframework.http.HttpHeaders)2 RestOperations (org.springframework.web.client.RestOperations)2 SecHubTimeUnitData (com.mercedesbenz.sechub.adapter.SecHubTimeUnitData)1 CheckmarxScanSupport (com.mercedesbenz.sechub.adapter.checkmarx.support.CheckmarxScanSupport)1 CheckmarxUploadSupport (com.mercedesbenz.sechub.adapter.checkmarx.support.CheckmarxUploadSupport)1 NetsparkerConfigBuilder (com.mercedesbenz.sechub.adapter.netsparker.NetsparkerConfig.NetsparkerConfigBuilder)1