Search in sources :

Example 16 with ProductExecutorConfig

use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig 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)16 ProductExecutorConfigSetup (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetup)9 Test (org.junit.Test)6 SecHubExecutionContext (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext)5 SecHubConfiguration (com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration)4 ProductExecutorConfigRepository (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigRepository)3 ProductExecutorConfigSetupJobParameter (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetupJobParameter)3 ValidationResult (com.mercedesbenz.sechub.sharedkernel.validation.ValidationResult)3 Before (org.junit.Before)3 AdapterException (com.mercedesbenz.sechub.adapter.AdapterException)2 AdapterLogId (com.mercedesbenz.sechub.adapter.AdapterLogId)2 ProductExecutorCallback (com.mercedesbenz.sechub.domain.scan.product.ProductExecutorCallback)2 ProductExecutorContext (com.mercedesbenz.sechub.domain.scan.product.ProductExecutorContext)2 ProductResult (com.mercedesbenz.sechub.domain.scan.product.ProductResult)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 UUID (java.util.UUID)2 ScanType (com.mercedesbenz.sechub.commons.model.ScanType)1 SecHubInfrastructureScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubInfrastructureScanConfiguration)1 SecHubWebScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration)1