Search in sources :

Example 1 with CheckmarxConfig

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

the class CheckmarxProjectSupportTest method updatePresetIdWhenSetInAdapterConfig_preset_id_set_in_sechub.

@Test
public void updatePresetIdWhenSetInAdapterConfig_preset_id_set_in_sechub() {
    /* prepare */
    long secHubPresetId = 39203;
    long checkmarxPresetId = 1;
    CheckmarxConfigBuilder builder = createBuilderWithMandatoryParamatersSet();
    builder.setPresetIdForNewProjects(secHubPresetId);
    CheckmarxConfig config = builder.build();
    CheckmarxSastScanSettings checkmarxScanSettings = new CheckmarxSastScanSettings();
    checkmarxScanSettings.setPresetId(checkmarxPresetId);
    InternalUpdateContext updateContext = supportToTest.new InternalUpdateContext();
    /* execute */
    supportToTest.updatePresetIdWhenSetInAdapterConfig(config, checkmarxScanSettings, updateContext);
    /* test */
    assertThat(updateContext.isUpdateOfPresetIdNecessary(), is(true));
    assertThat(updateContext.getPresetId(), is(secHubPresetId));
    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) CheckmarxConfig(com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxConfig) Test(org.junit.Test)

Example 2 with CheckmarxConfig

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

the class CheckmarxProjectSupportTest method updatePresetIdWhenSetInAdapterConfig_presetId_sechub_not_set__no_update_necessary.

@Test
public void updatePresetIdWhenSetInAdapterConfig_presetId_sechub_not_set__no_update_necessary() {
    /* prepare */
    long presetId = 443940;
    CheckmarxConfigBuilder builder = createBuilderWithMandatoryParamatersSet();
    builder.setPresetIdForNewProjects(null);
    CheckmarxConfig config = builder.build();
    CheckmarxSastScanSettings checkmarxScanSettings = new CheckmarxSastScanSettings();
    checkmarxScanSettings.setPresetId(presetId);
    InternalUpdateContext updateContext = supportToTest.new InternalUpdateContext();
    /* execute */
    supportToTest.updatePresetIdWhenSetInAdapterConfig(config, checkmarxScanSettings, updateContext);
    /* test */
    assertThat(updateContext.isUpdateOfPresetIdNecessary(), is(false));
    assertThat(updateContext.getPresetId(), is(presetId));
    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) CheckmarxConfig(com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxConfig) Test(org.junit.Test)

Example 3 with CheckmarxConfig

use of com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxConfig 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 4 with CheckmarxConfig

use of com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxConfig 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

CheckmarxConfig (com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxConfig)4 CheckmarxConfigBuilder (com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxConfig.CheckmarxConfigBuilder)4 CheckmarxSastScanSettings (com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxSastScanSettings)4 InternalUpdateContext (com.mercedesbenz.sechub.adapter.checkmarx.support.CheckmarxProjectSupport.InternalUpdateContext)4 Test (org.junit.Test)4 CheckmarxEngineConfiguration (com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxEngineConfiguration)2 LinkedList (java.util.LinkedList)2