Search in sources :

Example 6 with CheckmarxEngineConfiguration

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

the class CheckmarxProjectSupportTest method updateEngineCondfigurationIdWhenSecHubAndCheckmarxDiffer_same_engine_configuration_id.

@Test
public void updateEngineCondfigurationIdWhenSecHubAndCheckmarxDiffer_same_engine_configuration_id() {
    /* prepare */
    String engineConfigurationName = "test-configuration";
    long engineConfigurationId = 5L;
    List<CheckmarxEngineConfiguration> engineConfigurations = new LinkedList<>();
    CheckmarxEngineConfiguration defaultConfiguration = new CheckmarxEngineConfiguration();
    defaultConfiguration.setId(1L);
    defaultConfiguration.setName("Default Configuration");
    CheckmarxEngineConfiguration testConfiguration = new CheckmarxEngineConfiguration();
    testConfiguration.setId(engineConfigurationId);
    testConfiguration.setName(engineConfigurationName);
    engineConfigurations.add(defaultConfiguration);
    engineConfigurations.add(testConfiguration);
    CheckmarxConfigBuilder builder = createBuilderWithMandatoryParamatersSet();
    builder.setEngineConfigurationName(engineConfigurationName);
    CheckmarxConfig config = builder.build();
    CheckmarxSastScanSettings checkmarxScanSettings = new CheckmarxSastScanSettings();
    checkmarxScanSettings.setEngineConfigurationId(engineConfigurationId);
    InternalUpdateContext updateContext = supportToTest.new InternalUpdateContext();
    /* execute */
    supportToTest.updateEngineCondfigurationIdWhenSecHubAndCheckmarxDiffer(config, engineConfigurations, checkmarxScanSettings, updateContext);
    /* test */
    assertThat(updateContext.isUpdateOfEngineConfigurationNecessary(), is(false));
    assertThat(updateContext.getEngineConfigurationId(), is(engineConfigurationId));
    assertThat(updateContext.isUpdateNecessary(), is(false));
}
Also used : InternalUpdateContext(com.mercedesbenz.sechub.adapter.checkmarx.support.CheckmarxProjectSupport.InternalUpdateContext) CheckmarxConfigBuilder(com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxConfig.CheckmarxConfigBuilder) CheckmarxSastScanSettings(com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxSastScanSettings) CheckmarxEngineConfiguration(com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxEngineConfiguration) LinkedList(java.util.LinkedList) CheckmarxConfig(com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxConfig) Test(org.junit.Test)

Example 7 with CheckmarxEngineConfiguration

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

the class CheckmarxProjectSupportTest method engine_configurations_can_be_extracted.

@Test
public void engine_configurations_can_be_extracted() throws AdapterException {
    /* prepare */
    String json_data = "[\n" + "   {\n" + "     \"id\": 1,\n" + "     \"name\": \"Default Configuration\"\n" + "   },\n" + "   {\n" + "     \"id\": 2,\n" + "     \"name\": \"Japanese (Shift-JIS)\"\n" + "   },\n" + "   {\n" + "     \"id\": 3,\n" + "     \"name\": \"Korean\"\n" + "   },\n" + "   {\n" + "     \"id\": 5,\n" + "     \"name\": \"Multi-language Scan\"\n" + "   }\n" + " ]";
    CheckmarxEngineConfiguration multiLanguageScanConfiguration = new CheckmarxEngineConfiguration();
    multiLanguageScanConfiguration.setId(5L);
    multiLanguageScanConfiguration.setName(CheckmarxConstants.DEFAULT_CHECKMARX_ENGINECONFIGURATION_MULTILANGANGE_SCAN_NAME);
    /* execute */
    List<CheckmarxEngineConfiguration> engineConfigurations = supportToTest.extractEngineConfigurationsFromGet(json_data, JSONAdapterSupport.FOR_UNKNOWN_ADAPTER);
    /* test */
    assertThat((Object) engineConfigurations, notNullValue());
    assertThat(engineConfigurations, not(empty()));
    assertThat(engineConfigurations, hasSize(4));
    assertThat(engineConfigurations, hasItem(multiLanguageScanConfiguration));
}
Also used : CheckmarxEngineConfiguration(com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxEngineConfiguration) Test(org.junit.Test)

Example 8 with CheckmarxEngineConfiguration

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

the class CheckmarxProjectSupportTest method updateEngineCondfigurationIdWhenSecHubAndCheckmarxDiffer_different_engine_configuration_id.

@Test
public void updateEngineCondfigurationIdWhenSecHubAndCheckmarxDiffer_different_engine_configuration_id() {
    /* prepare */
    String engineConfigurationName = "test-configuration";
    long engineConfigurationId = 5L;
    List<CheckmarxEngineConfiguration> engineConfigurations = new LinkedList<>();
    CheckmarxEngineConfiguration defaultConfiguration = new CheckmarxEngineConfiguration();
    defaultConfiguration.setId(1L);
    defaultConfiguration.setName("Default Configuration");
    CheckmarxEngineConfiguration testConfiguration = new CheckmarxEngineConfiguration();
    testConfiguration.setId(engineConfigurationId);
    testConfiguration.setName(engineConfigurationName);
    engineConfigurations.add(defaultConfiguration);
    engineConfigurations.add(testConfiguration);
    CheckmarxConfigBuilder builder = createBuilderWithMandatoryParamatersSet();
    builder.setEngineConfigurationName(engineConfigurationName);
    CheckmarxConfig config = builder.build();
    CheckmarxSastScanSettings checkmarxScanSettings = new CheckmarxSastScanSettings();
    checkmarxScanSettings.setEngineConfigurationId(defaultConfiguration.getId());
    InternalUpdateContext updateContext = supportToTest.new InternalUpdateContext();
    /* execute */
    supportToTest.updateEngineCondfigurationIdWhenSecHubAndCheckmarxDiffer(config, engineConfigurations, checkmarxScanSettings, updateContext);
    /* test */
    assertThat(updateContext.isUpdateOfEngineConfigurationNecessary(), is(true));
    assertThat(updateContext.getEngineConfigurationId(), is(engineConfigurationId));
    assertThat(updateContext.isUpdateNecessary(), is(true));
}
Also used : InternalUpdateContext(com.mercedesbenz.sechub.adapter.checkmarx.support.CheckmarxProjectSupport.InternalUpdateContext) CheckmarxConfigBuilder(com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxConfig.CheckmarxConfigBuilder) CheckmarxSastScanSettings(com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxSastScanSettings) CheckmarxEngineConfiguration(com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxEngineConfiguration) LinkedList(java.util.LinkedList) CheckmarxConfig(com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxConfig) Test(org.junit.Test)

Aggregations

CheckmarxEngineConfiguration (com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxEngineConfiguration)8 LinkedList (java.util.LinkedList)4 Test (org.junit.Test)4 CheckmarxSastScanSettings (com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxSastScanSettings)3 CheckmarxConfig (com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxConfig)2 CheckmarxConfigBuilder (com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxConfig.CheckmarxConfigBuilder)2 InternalUpdateContext (com.mercedesbenz.sechub.adapter.checkmarx.support.CheckmarxProjectSupport.InternalUpdateContext)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 CheckmarxAdapterConfig (com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxAdapterConfig)1 Access (com.mercedesbenz.sechub.adapter.support.JSONAdapterSupport.Access)1 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)1 RestOperations (org.springframework.web.client.RestOperations)1