Search in sources :

Example 6 with CheckmarxConfigBuilder

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

the class CheckmarxConfigTest method builder_creates_config_with_given_client_secret_when_set.

@Test
public void builder_creates_config_with_given_client_secret_when_set() {
    /* prepare */
    String newSecret = "test-secret";
    CheckmarxConfigBuilder builder = createBuilderWithMandatoryParamatersSet();
    builder.setClientSecret(newSecret);
    /* execute */
    CheckmarxConfig config = builder.build();
    /* test */
    assertEquals(newSecret, config.getClientSecret());
}
Also used : CheckmarxConfigBuilder(com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxConfig.CheckmarxConfigBuilder) Test(org.junit.Test)

Example 7 with CheckmarxConfigBuilder

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

the class CheckmarxConfigTest method builder_creates_config_with_default_client_secret_when_not_set.

@Test
public void builder_creates_config_with_default_client_secret_when_not_set() {
    /* prepare */
    CheckmarxConfigBuilder builder = createBuilderWithMandatoryParamatersSet();
    /* execute */
    CheckmarxConfig config = builder.build();
    /* test */
    assertEquals(CheckmarxConfig.DEFAULT_CLIENT_SECRET, config.getClientSecret());
}
Also used : CheckmarxConfigBuilder(com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxConfig.CheckmarxConfigBuilder) Test(org.junit.Test)

Example 8 with CheckmarxConfigBuilder

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

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

Example 10 with CheckmarxConfigBuilder

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

the class CheckmarxProjectSupportTest method createBuilderWithMandatoryParamatersSet.

private CheckmarxConfigBuilder createBuilderWithMandatoryParamatersSet() {
    CheckmarxConfigBuilder builder = CheckmarxConfig.builder();
    builder.setUser("testuserId");
    builder.setPasswordOrAPIToken("testapitoken");
    builder.setProjectId("testprojectid");
    builder.setTeamIdForNewProjects("testteamid");
    return builder;
}
Also used : CheckmarxConfigBuilder(com.mercedesbenz.sechub.adapter.checkmarx.CheckmarxConfig.CheckmarxConfigBuilder)

Aggregations

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