Search in sources :

Example 6 with OwaspZapScanConfiguration

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);
}
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 7 with OwaspZapScanConfiguration

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);
}
Also used : UnauthenticatedScan(com.mercedesbenz.sechub.owaspzapwrapper.scan.UnauthenticatedScan) OwaspZapScanConfiguration(com.mercedesbenz.sechub.owaspzapwrapper.config.OwaspZapScanConfiguration) 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 8 with OwaspZapScanConfiguration

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());
    }
}
Also used : OwaspZapScanConfiguration(com.mercedesbenz.sechub.owaspzapwrapper.config.OwaspZapScanConfiguration)

Aggregations

OwaspZapScanConfiguration (com.mercedesbenz.sechub.owaspzapwrapper.config.OwaspZapScanConfiguration)8 ClientApi (org.zaproxy.clientapi.core.ClientApi)6 Test (org.junit.jupiter.api.Test)5 OwaspZapScan (com.mercedesbenz.sechub.owaspzapwrapper.scan.OwaspZapScan)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 URI (java.net.URI)2 OwaspZapWrapperCommandLineParserException (com.mercedesbenz.sechub.owaspzapwrapper.cli.OwaspZapWrapperCommandLineParser.OwaspZapWrapperCommandLineParserException)1 UnauthenticatedScan (com.mercedesbenz.sechub.owaspzapwrapper.scan.UnauthenticatedScan)1 HTTPBasicAuthScan (com.mercedesbenz.sechub.owaspzapwrapper.scan.auth.HTTPBasicAuthScan)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1