Search in sources :

Example 1 with ClientApi

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();
}
Also used : OwaspZapScanConfiguration(com.mercedesbenz.sechub.owaspzapwrapper.config.OwaspZapScanConfiguration) ClientApi(org.zaproxy.clientapi.core.ClientApi) URI(java.net.URI) OwaspZapScan(com.mercedesbenz.sechub.owaspzapwrapper.scan.OwaspZapScan) Test(org.junit.jupiter.api.Test)

Example 2 with ClientApi

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));
}
Also used : OwaspZapScanConfiguration(com.mercedesbenz.sechub.owaspzapwrapper.config.OwaspZapScanConfiguration) ClientApi(org.zaproxy.clientapi.core.ClientApi) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with 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);
}
Also used : OwaspZapScanConfiguration(com.mercedesbenz.sechub.owaspzapwrapper.config.OwaspZapScanConfiguration) HTTPBasicAuthScan(com.mercedesbenz.sechub.owaspzapwrapper.scan.auth.HTTPBasicAuthScan) ClientApi(org.zaproxy.clientapi.core.ClientApi) OwaspZapScan(com.mercedesbenz.sechub.owaspzapwrapper.scan.OwaspZapScan) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with ClientApi

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));
}
Also used : OwaspZapScanConfiguration(com.mercedesbenz.sechub.owaspzapwrapper.config.OwaspZapScanConfiguration) ClientApi(org.zaproxy.clientapi.core.ClientApi) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with 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);
}
Also used : ClientApi(org.zaproxy.clientapi.core.ClientApi) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ClientApi (org.zaproxy.clientapi.core.ClientApi)13 OwaspZapScanConfiguration (com.mercedesbenz.sechub.owaspzapwrapper.config.OwaspZapScanConfiguration)6 Test (org.junit.jupiter.api.Test)6 OwaspZapScan (com.mercedesbenz.sechub.owaspzapwrapper.scan.OwaspZapScan)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 Proxy (org.openqa.selenium.Proxy)4 ChromeOptions (org.openqa.selenium.chrome.ChromeOptions)3 URI (java.net.URI)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 UnauthenticatedScan (com.mercedesbenz.sechub.owaspzapwrapper.scan.UnauthenticatedScan)1 HTTPBasicAuthScan (com.mercedesbenz.sechub.owaspzapwrapper.scan.auth.HTTPBasicAuthScan)1 Before (org.junit.Before)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1 BeforeMethod (org.testng.annotations.BeforeMethod)1