use of org.zaproxy.clientapi.core.ClientApi 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 org.zaproxy.clientapi.core.ClientApi 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 org.zaproxy.clientapi.core.ClientApi 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 org.zaproxy.clientapi.core.ClientApi 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 org.zaproxy.clientapi.core.ClientApi in project sechub by mercedes-benz.
the class OwaspZapClientApiFactoryTest method valid_configuration_returns_clientapi_object.
@Test
void valid_configuration_returns_clientapi_object() throws ClientApiException {
/* prepare */
OwaspZapServerConfiguration serverConfig = new OwaspZapServerConfiguration("127.0.0.1", 8080, "secret-key");
/* execute */
ClientApi clientApi = factoryToTest.create(serverConfig);
/* test */
assertNotNull(clientApi);
}
Aggregations