use of com.mercedesbenz.sechub.owaspzapwrapper.config.OwaspZapScanConfiguration in project sechub by mercedes-benz.
the class OwaspZapScanExecutorTest method the_result_from_resolver_returned_is_executed.
@Test
void the_result_from_resolver_returned_is_executed() throws Exception {
/* prepare */
OwaspZapScanConfiguration scanConfig = mock(OwaspZapScanConfiguration.class);
ClientApi clientApi = mock(ClientApi.class);
URI targetUri = new URI("http://www.example.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(true);
/* execute */
executorToTest.execute(scanConfig);
/* test */
verify(connectionChecker).isTargetReachable(targetUri, null);
verify(clientApiFactory).create(scanConfig.getServerConfig());
verify(resolver).resolveScanImplementation(scanConfig, clientApi);
verify(scan).scan();
}
use of com.mercedesbenz.sechub.owaspzapwrapper.config.OwaspZapScanConfiguration in project sechub by mercedes-benz.
the class OwaspZapScanResolverTest method authenticationtype_null_is_throwing_mustexitruntimeexception.
@Test
void authenticationtype_null_is_throwing_mustexitruntimeexception() {
/* prepare */
OwaspZapScanConfiguration scanConfig = mock(OwaspZapScanConfiguration.class);
when(scanConfig.getAuthenticationType()).thenReturn(null);
ClientApi clientApi = mock(ClientApi.class);
/* execute + test */
assertThrows(MustExitRuntimeException.class, () -> resolverToTest.resolveScanImplementation(scanConfig, clientApi));
}
use of com.mercedesbenz.sechub.owaspzapwrapper.config.OwaspZapScanConfiguration in project sechub by mercedes-benz.
the class OwaspZapScanResolverTest method http_basic_authentication_scan_is_resolved_correctly.
@Test
void http_basic_authentication_scan_is_resolved_correctly() {
/* prepare */
OwaspZapScanConfiguration scanConfig = mock(OwaspZapScanConfiguration.class);
when(scanConfig.getAuthenticationType()).thenReturn(AuthenticationType.HTTP_BASIC_AUTHENTICATION);
ClientApi clientApi = mock(ClientApi.class);
/* execute */
OwaspZapScan scan = resolverToTest.resolveScanImplementation(scanConfig, clientApi);
/* test */
assertTrue(scan instanceof HTTPBasicAuthScan);
}
use of com.mercedesbenz.sechub.owaspzapwrapper.config.OwaspZapScanConfiguration in project sechub by mercedes-benz.
the class OwaspZapScanResolverTest method not_yet_supported_authenticationtype_is_throwing_mustexitruntimeexception.
@ParameterizedTest
@EnumSource(value = AuthenticationType.class, names = { "FORM_BASED_AUTHENTICATION", "SCRIPT_BASED_AUTHENTICATION", "JSON_BASED_AUTHENTICATION" })
void not_yet_supported_authenticationtype_is_throwing_mustexitruntimeexception(AuthenticationType authType) {
/* prepare */
OwaspZapScanConfiguration scanConfig = mock(OwaspZapScanConfiguration.class);
when(scanConfig.getAuthenticationType()).thenReturn(authType);
ClientApi clientApi = mock(ClientApi.class);
/* execute + test */
assertThrows(MustExitRuntimeException.class, () -> resolverToTest.resolveScanImplementation(scanConfig, clientApi));
}
use of com.mercedesbenz.sechub.owaspzapwrapper.config.OwaspZapScanConfiguration in project sechub by mercedes-benz.
the class OwaspZapWrapperCLI method resolveScanConfiguration.
private OwaspZapScanConfiguration resolveScanConfiguration(String[] args) {
OwaspZapWrapperCommandLineParser parser = new OwaspZapWrapperCommandLineParser();
OwaspZapScanConfiguration scanConfig = null;
try {
scanConfig = parser.parse(args);
} catch (OwaspZapWrapperCommandLineParserException e) {
LOG.error("An error occurred while parsing the command line arguments: ", e.getCause());
throw new MustExitRuntimeException("Scan configuration was invalid.", e, MustExitCode.COMMANDLINE_CONFIGURATION_INVALID);
}
return scanConfig;
}
Aggregations