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