Search in sources :

Example 1 with ProductExecutorConfigRepository

use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigRepository 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);
}
Also used : UUIDTraceLogID(com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID) ProductExecutorConfig(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig) Logger(org.slf4j.Logger) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) ProductExecutorConfigRepository(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigRepository) ProductExecutorConfigSetup(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetup) Before(org.junit.Before)

Example 2 with ProductExecutorConfigRepository

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

the class WebScanProductExecutionServiceImplTest method before.

@Before
public void before() throws Exception {
    uri = new URI("https://www.example.org");
    configuration = mock(SecHubConfiguration.class);
    when(configuration.getProjectId()).thenReturn(PROJECT_ID1);
    productExecutorContext = mock(ProductExecutorContext.class);
    webconfiguration = mock(SecHubWebScanConfiguration.class);
    context = mock(SecHubExecutionContext.class);
    ProductResultRepository productResultRepository = mock(ProductResultRepository.class);
    webscanner1 = mock(WebScanProductExecutor.class);
    when(webscanner1.getIdentifier()).thenReturn(PRODUCT_IDENTIFIER_1);
    when(webscanner1.getVersion()).thenReturn(1);
    webscanner2 = mock(WebScanProductExecutor.class);
    when(webscanner2.getIdentifier()).thenReturn(PRODUCT_IDENTIFIER_2);
    when(webscanner2.getVersion()).thenReturn(2);
    when(webconfiguration.getUri()).thenReturn(uri);
    when(context.getConfiguration()).thenReturn(configuration);
    List<WebScanProductExecutor> executors = new ArrayList<>();
    executors.add(webscanner1);
    executors.add(webscanner2);
    productExecutorConfigRepository = mock(ProductExecutorConfigRepository.class);
    /* simulate default profile1 */
    when(productExecutorConfigRepository.findExecutableConfigurationsForProject(eq(PROJECT_ID1), eq(PRODUCT_IDENTIFIER_1), eq(1))).thenReturn(Arrays.asList(new ProductExecutorConfig(PRODUCT_IDENTIFIER_1, 1, new ProductExecutorConfigSetup())));
    when(productExecutorConfigRepository.findExecutableConfigurationsForProject(eq(PROJECT_ID1), eq(PRODUCT_IDENTIFIER_2), eq(2))).thenReturn(Arrays.asList(new ProductExecutorConfig(PRODUCT_IDENTIFIER_2, 2, new ProductExecutorConfigSetup())));
    serviceToTest = new WebScanProductExecutionServiceImpl(executors);
    serviceToTest.productResultRepository = productResultRepository;
    productExecutorContextFactory = mock(ProductExecutorContextFactory.class);
    serviceToTest.productExecutorContextFactory = productExecutorContextFactory;
    serviceToTest.productExecutorConfigRepository = productExecutorConfigRepository;
    when(productExecutorContextFactory.create(any(), any(), any(), any())).thenReturn(productExecutorContext);
}
Also used : SecHubWebScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration) ArrayList(java.util.ArrayList) ProductExecutorConfig(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig) URI(java.net.URI) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) ProductExecutorConfigRepository(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigRepository) ProductExecutorConfigSetup(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetup) Before(org.junit.Before)

Example 3 with ProductExecutorConfigRepository

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

the class InfrastructureScanProductExecutionServiceImplTest method before.

@Before
public void before() throws Exception {
    infraScanProductExecutorConfigInfo = new WithoutProductExecutorConfigInfo(INFRASCANNER1_PRODUCT_IDENTIFIER);
    uri = new URI("https://www.example.org");
    configuration = mock(SecHubConfiguration.class);
    when(configuration.getProjectId()).thenReturn(PROJECT_ID1);
    productExecutorContext = mock(ProductExecutorContext.class);
    infraconfig = mock(SecHubInfrastructureScanConfiguration.class);
    context = mock(SecHubExecutionContext.class);
    ProductResultRepository productResultRepository = mock(ProductResultRepository.class);
    infrascanner1 = mock(InfrastructureScanProductExecutor.class, "infrascanner1");
    when(infrascanner1.getIdentifier()).thenReturn(INFRASCANNER1_PRODUCT_IDENTIFIER);
    when(infrascanner1.getVersion()).thenReturn(1);
    infrascanner2 = mock(InfrastructureScanProductExecutor.class, "infrascanner2");
    when(infrascanner2.getIdentifier()).thenReturn(INFRASCANNER2_PRODUCT_IDENTIFIER);
    when(infrascanner2.getVersion()).thenReturn(2);
    when(infraconfig.getUris()).thenReturn(Collections.singletonList(uri));
    when(context.getConfiguration()).thenReturn(configuration);
    List<InfrastructureScanProductExecutor> executors = new ArrayList<>();
    executors.add(infrascanner1);
    executors.add(infrascanner2);
    productExecutorConfigRepository = mock(ProductExecutorConfigRepository.class);
    /* simulate default profile1 */
    when(productExecutorConfigRepository.findExecutableConfigurationsForProject(eq(PROJECT_ID1), eq(INFRASCANNER1_PRODUCT_IDENTIFIER), eq(1))).thenReturn(Arrays.asList(new ProductExecutorConfig(INFRASCANNER1_PRODUCT_IDENTIFIER, 1, new ProductExecutorConfigSetup())));
    when(productExecutorConfigRepository.findExecutableConfigurationsForProject(eq(PROJECT_ID1), eq(INFRASCANNER2_PRODUCT_IDENTIFIER), eq(2))).thenReturn(Arrays.asList(new ProductExecutorConfig(INFRASCANNER2_PRODUCT_IDENTIFIER, 2, new ProductExecutorConfigSetup())));
    serviceToTest = new InfrastructureScanProductExecutionServiceImpl(executors);
    serviceToTest.productResultRepository = productResultRepository;
    productExecutorContextFactory = mock(ProductExecutorContextFactory.class);
    serviceToTest.productExecutorContextFactory = productExecutorContextFactory;
    serviceToTest.productExecutorConfigRepository = productExecutorConfigRepository;
    when(productExecutorContextFactory.create(any(), any(), any(), any())).thenReturn(productExecutorContext);
}
Also used : ArrayList(java.util.ArrayList) ProductExecutorConfig(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig) URI(java.net.URI) WithoutProductExecutorConfigInfo(com.mercedesbenz.sechub.domain.scan.product.config.WithoutProductExecutorConfigInfo) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) ProductExecutorConfigRepository(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigRepository) SecHubInfrastructureScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubInfrastructureScanConfiguration) ProductExecutorConfigSetup(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetup) Before(org.junit.Before)

Aggregations

ProductExecutorConfig (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig)3 ProductExecutorConfigRepository (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigRepository)3 ProductExecutorConfigSetup (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetup)3 SecHubConfiguration (com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration)3 SecHubExecutionContext (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext)3 Before (org.junit.Before)3 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 SecHubInfrastructureScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubInfrastructureScanConfiguration)1 SecHubWebScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration)1 WithoutProductExecutorConfigInfo (com.mercedesbenz.sechub.domain.scan.product.config.WithoutProductExecutorConfigInfo)1 UUIDTraceLogID (com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID)1 Logger (org.slf4j.Logger)1