use of com.mercedesbenz.sechub.owaspzapwrapper.config.OwaspZapScanConfiguration in project sechub by mercedes-benz.
the class OwaspZapScanExecutorTest method target_is_not_reachable_throws_mustexitruntimeexception.
@Test
void target_is_not_reachable_throws_mustexitruntimeexception() throws Exception {
/* prepare */
OwaspZapScanConfiguration scanConfig = mock(OwaspZapScanConfiguration.class);
ClientApi clientApi = mock(ClientApi.class);
URI targetUri = new URI("http://www.my-url.com");
when(scanConfig.getTargetUri()).thenReturn(targetUri);
OwaspZapScan scan = mock(OwaspZapScan.class);
when(resolver.resolveScanImplementation(eq(scanConfig), any())).thenReturn(scan);
when(clientApiFactory.create(scanConfig.getServerConfig())).thenReturn(clientApi);
when(connectionChecker.isTargetReachable(targetUri, null)).thenReturn(false);
/* execute + test */
assertThrows(MustExitRuntimeException.class, () -> executorToTest.execute(scanConfig));
verify(connectionChecker).isTargetReachable(targetUri, null);
verify(scan, never()).scan();
verify(clientApiFactory, never()).create(scanConfig.getServerConfig());
verify(resolver, never()).resolveScanImplementation(scanConfig, clientApi);
}
use of com.mercedesbenz.sechub.owaspzapwrapper.config.OwaspZapScanConfiguration in project sechub by mercedes-benz.
the class OwaspZapScanResolverTest method unauthenticated_scan_is_resolved_correctly.
@Test
void unauthenticated_scan_is_resolved_correctly() {
/* prepare */
OwaspZapScanConfiguration scanConfig = mock(OwaspZapScanConfiguration.class);
when(scanConfig.getAuthenticationType()).thenReturn(AuthenticationType.UNAUTHENTICATED);
ClientApi clientApi = mock(ClientApi.class);
/* execute */
OwaspZapScan scan = resolverToTest.resolveScanImplementation(scanConfig, clientApi);
/* test */
assertTrue(scan instanceof UnauthenticatedScan);
}
use of com.mercedesbenz.sechub.owaspzapwrapper.config.OwaspZapScanConfiguration in project sechub by mercedes-benz.
the class OwaspZapWrapperCLI method start.
private void start(String[] args) {
try {
LOG.info("Building the scan configuration.");
OwaspZapScanConfiguration scanConfig = resolveScanConfiguration(args);
if (scanConfig == null) {
/* only happens when help command was executed - here we just exit with 0 */
System.exit(0);
}
LOG.info("Starting the scan.");
startExecution(scanConfig);
} catch (MustExitRuntimeException e) {
LOG.error("Must exit with exit code {} because: {}.", e.getExitCode().getExitCode(), e.getMessage(), e);
System.exit(e.getExitCode().getExitCode());
}
}
Aggregations