Search in sources :

Example 11 with ProductExecutorConfigSetupJobParameter

use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetupJobParameter in project sechub by mercedes-benz.

the class CheckmarxProductExecutorMinimumConfigValidation method validate.

@Override
protected void validate(ValidationContext<ProductExecutorConfig> context) {
    /* check not null... */
    validateNotNull(context);
    ProductExecutorConfig configToValidate = getObjectToValidate(context);
    if (configToValidate == null) {
        return;
    }
    ProductExecutorConfigSetup setup = configToValidate.getSetup();
    validateNotNull(context, setup, "setup");
    if (setup == null) {
        return;
    }
    List<ProductExecutorConfigSetupJobParameter> jobParameters = setup.getJobParameters();
    validateNotNull(context, jobParameters, "jobParameters");
    if (jobParameters == null) {
        return;
    }
    validateMandatoryPartsSet(context, jobParameters);
}
Also used : ProductExecutorConfigSetupJobParameter(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetupJobParameter) ProductExecutorConfig(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig) ProductExecutorConfigSetup(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetup)

Example 12 with ProductExecutorConfigSetupJobParameter

use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetupJobParameter in project sechub by mercedes-benz.

the class PDSProductExecutorMinimumConfigValidation method validateMandatoryPartsSet.

private void validateMandatoryPartsSet(ValidationContext<ProductExecutorConfig> context, List<ProductExecutorConfigSetupJobParameter> jobParameters) {
    /* check mandatory fields are set */
    for (PDSKeyProvider<?> provider : dataKeyProviders) {
        PDSKey key = provider.getKey();
        if (!key.isMandatory()) {
            continue;
        }
        ProductExecutorConfigSetupJobParameter found = null;
        for (ProductExecutorConfigSetupJobParameter parameter : jobParameters) {
            if (key.getId().equals(parameter.getKey())) {
                found = parameter;
                break;
            }
        }
        boolean notSet = false;
        if (found == null) {
            notSet = true;
        } else {
            String value = found.getValue();
            if (value == null) {
                notSet = true;
            } else {
                notSet = value.trim().isEmpty();
            }
        }
        if (notSet) {
            addErrorMessage(context, "Mandatory field:" + key.getId() + " not set.");
        }
    }
}
Also used : ProductExecutorConfigSetupJobParameter(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetupJobParameter) PDSKey(com.mercedesbenz.sechub.commons.pds.PDSKey)

Example 13 with ProductExecutorConfigSetupJobParameter

use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetupJobParameter in project sechub by mercedes-benz.

the class PDSExecutorConfigSuppportTest method before.

@Before
public void before() throws Exception {
    config = mock(ProductExecutorConfig.class);
    setup = mock(ProductExecutorConfigSetup.class);
    jobParameters = new ArrayList<>();
    jobParameters.add(new ProductExecutorConfigSetupJobParameter(PDSConfigDataKeyProvider.PDS_CONFIG_PRODUCTIDENTIFIER.getKey().getId(), CONFIGURED_PDS_PRODUCT_IDENTIFIER));
    jobParameters.add(new ProductExecutorConfigSetupJobParameter(SecHubProductExecutionPDSKeyProvider.PDS_FORBIDS_TARGETTYPE_INTERNET.getKey().getId(), "true"));
    jobParameters.add(new ProductExecutorConfigSetupJobParameter(SecHubProductExecutionPDSKeyProvider.PDS_FORBIDS_TARGETTYPE_INTRANET.getKey().getId(), "false"));
    when(config.getSetup()).thenReturn(setup);
    credentialsInConfigSetup = new ProductExecutorConfigSetupCredentials();
    when(setup.getCredentials()).thenReturn(credentialsInConfigSetup);
    when(setup.getJobParameters()).thenReturn(jobParameters);
    systemEnvironment = mock(SystemEnvironment.class);
    supportToTest = PDSExecutorConfigSuppport.createSupportAndAssertConfigValid(config, systemEnvironment);
}
Also used : SystemEnvironment(com.mercedesbenz.sechub.sharedkernel.SystemEnvironment) ProductExecutorConfigSetupJobParameter(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetupJobParameter) ProductExecutorConfigSetupCredentials(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetupCredentials) ProductExecutorConfig(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig) ProductExecutorConfigSetup(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetup) Before(org.junit.Before)

Aggregations

ProductExecutorConfigSetupJobParameter (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetupJobParameter)13 Test (org.junit.Test)6 ProductExecutorConfig (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig)5 ProductExecutorConfigSetup (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetup)5 ProductExecutorConfigSetupCredentials (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetupCredentials)3 SystemEnvironment (com.mercedesbenz.sechub.sharedkernel.SystemEnvironment)2 Before (org.junit.Before)2 ExecutionPDSKey (com.mercedesbenz.sechub.commons.pds.ExecutionPDSKey)1 PDSConfigDataKeyProvider (com.mercedesbenz.sechub.commons.pds.PDSConfigDataKeyProvider)1 PDSKey (com.mercedesbenz.sechub.commons.pds.PDSKey)1 MappingData (com.mercedesbenz.sechub.sharedkernel.mapping.MappingData)1 MappingEntry (com.mercedesbenz.sechub.sharedkernel.mapping.MappingEntry)1 ArrayList (java.util.ArrayList)1