use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig in project sechub by mercedes-benz.
the class AbstractProductExecutionServiceTest method before.
@Before
public void before() throws Exception {
serviceToTest = new TestImplAbstractProductExecutionService();
serviceToTest.allAvailableProductExecutors = new ArrayList<>();
SecHubConfiguration configuration = new SecHubConfiguration();
configuration.setProjectId("projectid1");
sechubJobUUID = UUID.randomUUID();
logger = mock(Logger.class);
traceLogID = mock(UUIDTraceLogID.class);
executors = new ArrayList<>();
executor = mock(ProductExecutor.class);
when(executor.getIdentifier()).thenReturn(USED_PRODUCT_IDENTIFIER);
when(executor.getVersion()).thenReturn(USED_PRODUCT_EXECUTOR_VERSION);
executors.add(executor);
context = mock(SecHubExecutionContext.class);
when(context.getSechubJobUUID()).thenReturn(sechubJobUUID);
when(context.getConfiguration()).thenReturn(configuration);
ProductExecutorConfigRepository productExecutorConfigRepository = mock(ProductExecutorConfigRepository.class);
serviceToTest.productExecutorConfigRepository = productExecutorConfigRepository;
config1 = new ProductExecutorConfig(USED_PRODUCT_IDENTIFIER, 0, new ProductExecutorConfigSetup());
when(productExecutorConfigRepository.findExecutableConfigurationsForProject(any(), eq(USED_PRODUCT_IDENTIFIER), eq(USED_PRODUCT_EXECUTOR_VERSION))).thenReturn(Arrays.asList(config1));
productResultRepository = mock(ProductResultRepository.class);
serviceToTest.productResultRepository = productResultRepository;
productExecutorContextFactory = mock(ProductExecutorContextFactory.class);
serviceToTest.productExecutorContextFactory = productExecutorContextFactory;
productExecutorContext = mock(ProductExecutorContext.class);
when(productExecutorContextFactory.create(any(), any(), any(), any())).thenReturn(productExecutorContext);
}
use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig in project sechub by mercedes-benz.
the class PDSProductExecutorMinimumConfigValidationTest method createConfigWithNoParametersSet.
private ProductExecutorConfig createConfigWithNoParametersSet() {
ProductExecutorConfigSetup setup = new ProductExecutorConfigSetup();
ProductExecutorConfig config = new ProductExecutorConfig(ProductIdentifier.PDS_CODESCAN, 1, setup);
return config;
}
use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig in project sechub by mercedes-benz.
the class PDSProductExecutorMinimumConfigValidationTest method when_all_mandatory_parameters_are_set_we_got_no_error_messages.
@Test
public void when_all_mandatory_parameters_are_set_we_got_no_error_messages() {
/* prepare */
ProductExecutorConfig config = createConfigWithAllMandatoryParametersSet();
/* execute */
ValidationResult result = validationToTest.validate(config);
/* test */
if (!result.isValid()) {
fail("Result is not valid, failure message was:" + result.getErrorDescription());
}
assertEquals(0, result.getErrors().size());
}
use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig in project sechub by mercedes-benz.
the class AbstractProductExecutionService method runOnAllAvailableExecutors.
/**
* Executes product executors and stores results. If a result of an executor is
* <code>null</code> an error will be logged but
*
* @param executors
* @param context
* @param traceLogID
*/
protected void runOnAllAvailableExecutors(List<? extends ProductExecutor> executors, SecHubExecutionContext context, UUIDTraceLogID traceLogID) {
SecHubConfiguration configuration = context.getConfiguration();
requireNonNull(configuration, "Configuration must be set");
String projectId = configuration.getProjectId();
requireNonNull(projectId, "Project id must be set");
int countOfReportProductExecutor = 0;
ProductExecutor serecoProductExecutor = null;
for (ProductExecutor productExecutor : executors) {
if (context.isCanceledOrAbandonded()) {
return;
}
ProductIdentifier productIdentifier = productExecutor.getIdentifier();
int executorVersion = productExecutor.getVersion();
switch(productIdentifier) {
case SERECO:
serecoProductExecutor = productExecutor;
/* fall through */
default:
LOG.debug("search config for project={}, executor={}, version={}", projectId, productIdentifier, executorVersion);
List<ProductExecutorConfig> executorConfigurations = productExecutorConfigRepository.findExecutableConfigurationsForProject(projectId, productIdentifier, executorVersion);
if (executorConfigurations.isEmpty()) {
LOG.debug("no config found for project={} so skipping executor={}, version={}", projectId, productIdentifier, executorVersion);
continue;
}
for (ProductExecutorConfig executorConfiguration : executorConfigurations) {
runOnExecutorWithOneConfiguration(executorConfiguration, productExecutor, context, projectId, traceLogID);
ScanType scanType = productExecutor.getScanType();
if (ScanType.REPORT.equals(scanType)) {
countOfReportProductExecutor++;
}
}
}
}
if (serecoProductExecutor != null && countOfReportProductExecutor == 0) {
LOG.debug("no dedicated configuration for report execution was executed before, so fallback to sereco default behaviour");
runOnExecutorWithOneConfiguration(SERECO_FALLBACK, serecoProductExecutor, context, projectId, traceLogID);
}
}
use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig in project sechub by mercedes-benz.
the class AbstractProductExecutionService method createFallbackExecutorConfigForSereco.
private static ProductExecutorConfig createFallbackExecutorConfigForSereco() {
ProductExecutorConfigSetup setup = new ProductExecutorConfigSetup();
ProductExecutorConfig executorConfiguration = new ProductExecutorConfig(ProductIdentifier.SERECO, 1, setup);
executorConfiguration.getSetup().setBaseURL("embedded");
return executorConfiguration;
}
Aggregations