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);
}
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.");
}
}
}
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);
}
Aggregations