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);
}
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());
}
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());
}
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);
}
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);
}
Aggregations