use of com.mercedesbenz.sechub.domain.scan.Target in project sechub by mercedes-benz.
the class NessusProductExecutorTest method before.
@Before
public void before() throws Exception {
context = mock(SecHubExecutionContext.class);
config = mock(SecHubConfiguration.class);
target1 = new Target(URI_1, TargetType.INTERNET);
target2 = new Target(URI_2, TargetType.INTERNET);
target3 = new Target(URI_3, TargetType.INTERNET);
targetResolver = mock(TargetResolver.class);
when(targetResolver.resolveTarget(URI_1)).thenReturn(target1);
when(targetResolver.resolveTarget(URI_2)).thenReturn(target2);
when(targetResolver.resolveTarget(URI_3)).thenReturn(target3);
nessusAdapter = mock(NessusAdapter.class);
executorContext = mock(ProductExecutorContext.class);
executorConfig = mock(ProductExecutorConfig.class);
ProductResult productResult = mock(ProductResult.class);
when(executorContext.getExecutorConfig()).thenReturn(executorConfig);
when(executorContext.getCurrentProductResult()).thenReturn(productResult);
installSetup = mock(NessusInstallSetup.class);
when(installSetup.getBaseURL(any())).thenReturn("baseURL");
when(installSetup.getUserId(any())).thenReturn("user");
when(installSetup.getPassword(any())).thenReturn("password");
when(installSetup.isAbleToScan(TargetType.INTRANET)).thenReturn(false);
when(context.getConfiguration()).thenReturn(config);
when(context.getSechubJobUUID()).thenReturn(UUID.randomUUID());
executorToTest = new TestNessusProductExecutor();
executorToTest.installSetup = installSetup;
executorToTest.nessusAdapter = nessusAdapter;
}
use of com.mercedesbenz.sechub.domain.scan.Target in project sechub by mercedes-benz.
the class NessusProductExecutorTest method when_three_root_urls_are_configured_and_apter_can_handle_2_targets_of_same_type_the_adapter_is_called_1_times.
@Test
public void when_three_root_urls_are_configured_and_apter_can_handle_2_targets_of_same_type_the_adapter_is_called_1_times() throws Exception {
/* prepare */
when(executorConfig.getProductIdentifier()).thenReturn(ProductIdentifier.NETSPARKER);
Target target2ButIntranet = new Target(URI_2, TargetType.INTRANET);
when(targetResolver.resolveTarget(URI_2)).thenReturn(target2ButIntranet);
when(installSetup.isAbleToScan(TargetType.INTERNET)).thenReturn(true);
when(installSetup.isAbleToScan(TargetType.INTRANET)).thenReturn(false);
prepareInfraScanWithThreeURIs();
/* execute */
executorToTest.execute(context, executorContext);
/* test */
verify(nessusAdapter, times(1)).start(any(), any());
}
use of com.mercedesbenz.sechub.domain.scan.Target in project sechub by mercedes-benz.
the class NetsparkerProductExecutorTest method when_one_root_url_is_configured_and_adapter_can_handle_2_targets_the_adapter_is_called_1_time.
@Test
public void when_one_root_url_is_configured_and_adapter_can_handle_2_targets_the_adapter_is_called_1_time() throws Exception {
/* prepare */
when(installSetup.isAbleToScan(TargetType.INTERNET)).thenReturn(true);
when(installSetup.isAbleToScan(TargetType.INTRANET)).thenReturn(false);
// we "reuse" the URI_2 so its used in prepare method but as INTRANET target!
URI uriIntranet = URI_2_INTERNET;
// fake this as INTERNET target...
Target intranetTarget = new Target(uriIntranet, TargetType.INTRANET);
when(targetResolver.resolveTarget(uriIntranet)).thenReturn(intranetTarget);
prepareWebScanWithOneInternetURI();
/* execute */
executorToTest.execute(context, executorContext);
/* test */
verify(netsparkerAdapter, times(1)).start(any(), any());
}
use of com.mercedesbenz.sechub.domain.scan.Target in project sechub by mercedes-benz.
the class AbstractInstallSetupProductExecutorTest method before.
@Before
public void before() throws Exception {
urisForTarget = new ArrayList<>();
inetAdressesForTarget = new ArrayList<>();
context = mock(SecHubExecutionContext.class);
executorContext = mock(ProductExecutorContext.class);
target1 = new Target(URI_1, TargetType.INTERNET);
target2 = new Target(URI_2, TargetType.INTRANET);
target3 = new Target(URI_3, TargetType.INTERNET);
target4 = new Target(IP_ADRESS1, TargetType.INTRANET);
targetResolver = mock(TargetResolver.class);
when(targetResolver.resolveTarget(URI_1)).thenReturn(target1);
when(targetResolver.resolveTarget(URI_2)).thenReturn(target2);
when(targetResolver.resolveTarget(URI_3)).thenReturn(target3);
when(targetResolver.resolveTarget(IP_ADRESS1)).thenReturn(target4);
when(context.getSechubJobUUID()).thenReturn(UUID.randomUUID());
installSetup = mock(InstallSetup.class);
executorToTest = new TestInstallSetupProductExecutor();
executorToTest.targetResolver = targetResolver;
}
use of com.mercedesbenz.sechub.domain.scan.Target in project sechub by mercedes-benz.
the class AbstractCodeScanProductExecutor method tryToRegister.
private void tryToRegister(UUIDTraceLogID traceLogId, S setup, TargetRegistry registry, String folderPath) {
Target target = targetResolver.resolveTargetForPath(folderPath);
if (!setup.isAbleToScan(target.getType())) {
LOG.error("{}: setup not able to scan target {}", getIdentifier(), target);
return;
}
LOG.debug("{} register scan target:{}", traceLogId, target);
registry.register(target);
}
Aggregations