Search in sources :

Example 11 with WithoutProductExecutorConfigInfo

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

the class NetsparkerProductExecutorTest method before.

@Before
public void before() throws Exception {
    context = mock(SecHubExecutionContext.class);
    config = mock(SecHubConfiguration.class);
    executorContext = mock(ProductExecutorContext.class);
    target1 = new Target(URI_1_INTERNET, TargetType.INTERNET);
    target2 = new Target(URI_2_INTERNET, TargetType.INTERNET);
    target3 = new Target(URI_3_INTERNET, TargetType.INTERNET);
    targetResolver = mock(TargetResolver.class);
    when(targetResolver.resolveTarget(URI_1_INTERNET)).thenReturn(target1);
    when(targetResolver.resolveTarget(URI_2_INTERNET)).thenReturn(target2);
    when(targetResolver.resolveTarget(URI_3_INTERNET)).thenReturn(target3);
    netsparkerAdapter = mock(NetsparkerAdapter.class);
    when(context.getConfiguration()).thenReturn(config);
    UUID pseudoJobUUID = UUID.randomUUID();
    when(context.getSechubJobUUID()).thenReturn(pseudoJobUUID);
    when(executorContext.getCurrentProductResult()).thenReturn(new ProductResult(pseudoJobUUID, "project1", new WithoutProductExecutorConfigInfo(ProductIdentifier.NETSPARKER), "resullt1"));
    executorToTest = new TestNetsparkerProductExecutor();
    executorToTest.netsparkerAdapter = netsparkerAdapter;
    installSetup = mock(NetsparkerInstallSetup.class);
    when(installSetup.getBaseURL()).thenReturn("http://www.example.com/netsparker");
    when(installSetup.getUserId()).thenReturn("user");
    when(installSetup.getPassword()).thenReturn("apitoken1");
    when(installSetup.getNetsparkerLicenseId()).thenReturn("license1");
    executorToTest.installSetup = installSetup;
}
Also used : NetsparkerAdapter(com.mercedesbenz.sechub.adapter.netsparker.NetsparkerAdapter) Target(com.mercedesbenz.sechub.domain.scan.Target) ProductResult(com.mercedesbenz.sechub.domain.scan.product.ProductResult) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) ProductExecutorContext(com.mercedesbenz.sechub.domain.scan.product.ProductExecutorContext) UUID(java.util.UUID) TargetResolver(com.mercedesbenz.sechub.domain.scan.resolve.TargetResolver) WithoutProductExecutorConfigInfo(com.mercedesbenz.sechub.domain.scan.product.config.WithoutProductExecutorConfigInfo) Before(org.junit.Before)

Example 12 with WithoutProductExecutorConfigInfo

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

the class WebScanProductExecutionServiceImplTest method webscanservice_persists_2_results_of_2_registered_webscan_product_executors.

@Test
public void webscanservice_persists_2_results_of_2_registered_webscan_product_executors() throws Exception {
    /* prepare */
    UUID secHubJobUUID = UUID.randomUUID();
    ProductResult result1 = new ProductResult(secHubJobUUID, "project1", new WithoutProductExecutorConfigInfo(PRODUCT_IDENTIFIER_1), "result1");
    ProductResultTestAccess.setUUID(result1, UUID.randomUUID());
    ProductResult result2 = new ProductResult(secHubJobUUID, "project1", new WithoutProductExecutorConfigInfo(PRODUCT_IDENTIFIER_2), "result2");
    ProductResultTestAccess.setUUID(result2, UUID.randomUUID());
    when(configuration.getWebScan()).thenReturn(Optional.of(webconfiguration));
    when(webscanner1.execute(context, productExecutorContext)).thenReturn(Collections.singletonList(result1));
    when(webscanner1.getIdentifier()).thenReturn(PRODUCT_IDENTIFIER_1);
    when(webscanner2.execute(context, productExecutorContext)).thenReturn(Collections.singletonList(result2));
    when(webscanner2.getIdentifier()).thenReturn(PRODUCT_IDENTIFIER_2);
    /* execute */
    serviceToTest.executeProductsAndStoreResults(context);
    /* test */
    verify(productExecutorContext).persist(result1);
    verify(productExecutorContext).persist(result2);
}
Also used : UUID(java.util.UUID) WithoutProductExecutorConfigInfo(com.mercedesbenz.sechub.domain.scan.product.config.WithoutProductExecutorConfigInfo) Test(org.junit.Test)

Example 13 with WithoutProductExecutorConfigInfo

use of com.mercedesbenz.sechub.domain.scan.product.config.WithoutProductExecutorConfigInfo 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

WithoutProductExecutorConfigInfo (com.mercedesbenz.sechub.domain.scan.product.config.WithoutProductExecutorConfigInfo)13 Test (org.junit.Test)10 UUID (java.util.UUID)9 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)6 ProductResult (com.mercedesbenz.sechub.domain.scan.product.ProductResult)4 SecHubConfiguration (com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration)2 SecHubExecutionContext (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext)2 ArrayList (java.util.ArrayList)2 Before (org.junit.Before)2 NetsparkerAdapter (com.mercedesbenz.sechub.adapter.netsparker.NetsparkerAdapter)1 SecHubInfrastructureScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubInfrastructureScanConfiguration)1 Target (com.mercedesbenz.sechub.domain.scan.Target)1 ProductExecutorContext (com.mercedesbenz.sechub.domain.scan.product.ProductExecutorContext)1 ProductExecutorConfig (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig)1 ProductExecutorConfigRepository (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigRepository)1 ProductExecutorConfigSetup (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigSetup)1 TargetResolver (com.mercedesbenz.sechub.domain.scan.resolve.TargetResolver)1 URI (java.net.URI)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1