Search in sources :

Example 1 with WithoutProductExecutorConfigInfo

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

the class WebScanProductExecutionServiceImplTest method webscanservice_persists_3_results_of_2_registered_webscan_product_executors.

@Test
public void webscanservice_persists_3_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());
    ProductResult result3 = new ProductResult(secHubJobUUID, "project1", new WithoutProductExecutorConfigInfo(PRODUCT_IDENTIFIER_2), "result3");
    ProductResultTestAccess.setUUID(result3, 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);
    List<ProductResult> list = new ArrayList<>();
    list.add(result2);
    list.add(result3);
    when(webscanner2.execute(context, productExecutorContext)).thenReturn(list);
    when(webscanner2.getIdentifier()).thenReturn(PRODUCT_IDENTIFIER_2);
    /* execute */
    serviceToTest.executeProductsAndStoreResults(context);
    /* test */
    verify(productExecutorContext).persist(result1);
    verify(productExecutorContext).persist(result2);
    verify(productExecutorContext).persist(result3);
}
Also used : ArrayList(java.util.ArrayList) UUID(java.util.UUID) WithoutProductExecutorConfigInfo(com.mercedesbenz.sechub.domain.scan.product.config.WithoutProductExecutorConfigInfo) Test(org.junit.Test)

Example 2 with WithoutProductExecutorConfigInfo

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

the class ProductResultRepositoryDBTest method a_standard_netsparker_output_can_be_persisted.

@Test
public void a_standard_netsparker_output_can_be_persisted() {
    /* prepare */
    String path = "netsparker/netsparker_v1.0.40.109_testresult1.xml";
    String netsparkerContent = ScanDomainTestFileSupport.getTestfileSupport().loadTestFile(path);
    UUID secHubJobUUID = UUID.randomUUID();
    ProductResult result1 = new ProductResult(secHubJobUUID, "project1", new WithoutProductExecutorConfigInfo(ProductIdentifier.NETSPARKER), netsparkerContent);
    /* execute */
    ProductResult result = repositoryToTest.save(result1);
    /* test */
    assertNotNull(result);
    assertNotNull(result.uUID);
    assertEquals(result, result1);
    assertEquals(netsparkerContent, result.getResult());
}
Also used : UUID(java.util.UUID) WithoutProductExecutorConfigInfo(com.mercedesbenz.sechub.domain.scan.product.config.WithoutProductExecutorConfigInfo) Test(org.junit.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 3 with WithoutProductExecutorConfigInfo

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

the class ProductResultRepositoryDBTest method findAllProductResults_results_is_executable_and_returns_pds_webscan_result_for_pds_webscan_and_netsparker.

@Test
public void findAllProductResults_results_is_executable_and_returns_pds_webscan_result_for_pds_webscan_and_netsparker() throws Exception {
    /* prepare */
    UUID secHubJobUUID = UUID.randomUUID();
    ProductResult result1 = new ProductResult(secHubJobUUID, "project1", new WithoutProductExecutorConfigInfo(ProductIdentifier.PDS_WEBSCAN), "result");
    entityManager.persistAndFlush(result1);
    /* execute */
    List<ProductResult> results = repositoryToTest.findAllProductResults(secHubJobUUID, NETSPARKER, PDS_WEBSCAN);
    /* test */
    assertNotNull(results);
    assertEquals(1, results.size());
    assertEquals(result1, results.iterator().next());
}
Also used : UUID(java.util.UUID) WithoutProductExecutorConfigInfo(com.mercedesbenz.sechub.domain.scan.product.config.WithoutProductExecutorConfigInfo) Test(org.junit.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 4 with WithoutProductExecutorConfigInfo

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

the class SecHubReportProductTransformerServiceTest method when_product_result_repository_returns_only_sereco_report_result__sechubResultFromTransformer_is_returned.

@Test
public void when_product_result_repository_returns_only_sereco_report_result__sechubResultFromTransformer_is_returned() throws Exception {
    /* prepare */
    ReportTransformationResult transformationResult = new ReportTransformationResult();
    ProductResult scanResult = new ProductResult(secHubJobUUID, "project1", new WithoutProductExecutorConfigInfo(ProductIdentifier.SERECO), "scan-result");
    when(reportTransformer.canTransform(ProductIdentifier.SERECO)).thenReturn(true);
    when(reportTransformer.transform(scanResult)).thenReturn(transformationResult);
    when(productResultRepository.findAllProductResults(eq(secHubJobUUID), any())).thenReturn(Arrays.asList(scanResult));
    when(resultMerger.merge(null, transformationResult)).thenReturn(transformationResult);
    /* execute */
    ReportTransformationResult result = serviceToTest.createResult(context);
    /* test */
    assertEquals(transformationResult, result);
}
Also used : ProductResult(com.mercedesbenz.sechub.domain.scan.product.ProductResult) WithoutProductExecutorConfigInfo(com.mercedesbenz.sechub.domain.scan.product.config.WithoutProductExecutorConfigInfo) Test(org.junit.Test)

Example 5 with WithoutProductExecutorConfigInfo

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

the class SecHubReportProductTransformerServiceTest method when_product_result_repository_returns_only_netsparker_result__sechub_execution_is_thrown_with_message.

@Test
public void when_product_result_repository_returns_only_netsparker_result__sechub_execution_is_thrown_with_message() throws Exception {
    /* prepare */
    ProductResult scanResult = new ProductResult(secHubJobUUID, "project1", new WithoutProductExecutorConfigInfo(ProductIdentifier.NETSPARKER), "scan-result");
    when(productResultRepository.findAllProductResults(eq(secHubJobUUID), any())).thenReturn(Arrays.asList(scanResult));
    /* test */
    expected.expect(SecHubExecutionException.class);
    /* execute */
    serviceToTest.createResult(context);
}
Also used : ProductResult(com.mercedesbenz.sechub.domain.scan.product.ProductResult) WithoutProductExecutorConfigInfo(com.mercedesbenz.sechub.domain.scan.product.config.WithoutProductExecutorConfigInfo) Test(org.junit.Test)

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