Search in sources :

Example 6 with WithoutProductExecutorConfigInfo

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

the class ProductResultRepositoryDBTest method findAllProductResults_is_executable_and_returns_pds_webscan_result_for_pds_webscan_and_netsparker.

@Test
public void findAllProductResults_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 7 with WithoutProductExecutorConfigInfo

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

the class ProductResultRepositoryDBTest method findProduct_results_is_executable_and_returns_empty_result_for_netsparker.

@Test
public void findProduct_results_is_executable_and_returns_empty_result_for_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);
    /* test */
    assertNotNull(results);
    assertTrue(results.isEmpty());
}
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 8 with WithoutProductExecutorConfigInfo

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

the class ProductResultRepositoryDBTest method findProduct_results_is_executable_and_returns_pds_webscan_result_for_pds_webscan.

@Test
public void findProduct_results_is_executable_and_returns_pds_webscan_result_for_pds_webscan() 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, 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 9 with WithoutProductExecutorConfigInfo

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

the class ProductResultRepositoryDBTest method given_3_stored_product_results_2_for_project1_1_for_project2_a_delete_all_for_project1_does_only_delete_project1_parts.

@Test
public void given_3_stored_product_results_2_for_project1_1_for_project2_a_delete_all_for_project1_does_only_delete_project1_parts() throws Exception {
    /* prepare */
    UUID job1_project1 = UUID.randomUUID();
    UUID job2_project2 = UUID.randomUUID();
    UUID job3_project1 = UUID.randomUUID();
    ProductResult result1 = new ProductResult(job1_project1, "project1", new WithoutProductExecutorConfigInfo(ProductIdentifier.SERECO), "result1");
    ProductResult result2 = new ProductResult(job2_project2, "project2", new WithoutProductExecutorConfigInfo(ProductIdentifier.SERECO), "result2");
    ProductResult result3 = new ProductResult(job3_project1, "project1", new WithoutProductExecutorConfigInfo(ProductIdentifier.SERECO), "result3");
    repositoryToTest.save(result1);
    repositoryToTest.save(result2);
    repositoryToTest.save(result3);
    /* check preconditions */
    assertEquals(3, repositoryToTest.count());
    assertNotNull(repositoryToTest.findById(job2_project2));
    /* execute */
    repositoryToTest.deleteAllResultsForProject("project1");
    /* test */
    assertEquals(1, repositoryToTest.count());
    assertNotNull(repositoryToTest.findById(job2_project2));
}
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 10 with WithoutProductExecutorConfigInfo

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

the class IntegrationTestScanRestController method changeScanResults.

@RequestMapping(path = APIConstants.API_ANONYMOUS + "integrationtest/project/{projectId}/job/{sechubJobUUID}/scan/productresult/{productIdentifier}", method = RequestMethod.PUT, produces = { MediaType.APPLICATION_JSON_VALUE })
public void changeScanResults(@RequestBody String body, @PathVariable("projectId") String projectId, @PathVariable("sechubJobUUID") UUID sechubJobUUID, @PathVariable("productIdentifier") ProductIdentifier productIdentifier) {
    List<ProductResult> originResults = productResultService.fetchAllResultsForJob(sechubJobUUID);
    ProductResult result = null;
    for (ProductResult originProductResult : originResults) {
        if (productIdentifier.equals(originProductResult.getProductIdentifier())) {
            result = originProductResult;
            break;
        }
    }
    ProductResult resultToPersist = null;
    if (result != null) {
        resultToPersist = result;
    } else {
        // We do not know which executor this has been done - it's a new one, so we
        // create just a new configuration info without UUID
        WithoutProductExecutorConfigInfo info = new WithoutProductExecutorConfigInfo(productIdentifier);
        resultToPersist = new ProductResult(sechubJobUUID, projectId, info, body);
    }
    resultToPersist.setResult(body);
    productResultRepository.save(resultToPersist);
}
Also used : ProductResult(com.mercedesbenz.sechub.domain.scan.product.ProductResult) WithoutProductExecutorConfigInfo(com.mercedesbenz.sechub.domain.scan.product.config.WithoutProductExecutorConfigInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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