Search in sources :

Example 1 with CommandLineSettings

use of com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings in project sechub by mercedes-benz.

the class OwaspZapScanConfigurationFactoryTest method authentication_type_from_config_is_in_result.

@Test
void authentication_type_from_config_is_in_result() {
    /* prepare */
    CommandLineSettings settings = createSettingsMockWithNecessaryParts();
    SecHubWebScanConfiguration config = simulateProvidedSecHubConfiguration(settings);
    AuthenticationType type = AuthenticationType.FORM_BASED_AUTHENTICATION;
    when(sechubWebConfigHelper.determineAuthenticationType(config)).thenReturn(type);
    /* execute */
    OwaspZapScanConfiguration result = factoryToTest.create(settings);
    /* test */
    assertEquals(result.getAuthenticationType(), type);
}
Also used : SecHubWebScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration) CommandLineSettings(com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings) AuthenticationType(com.mercedesbenz.sechub.owaspzapwrapper.config.auth.AuthenticationType) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with CommandLineSettings

use of com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings in project sechub by mercedes-benz.

the class OwaspZapScanConfigurationFactoryTest method ajaxspider_enabled_from_settings_is_in_result.

@ParameterizedTest
@CsvSource({ "true", "false" })
void ajaxspider_enabled_from_settings_is_in_result(boolean enabled) {
    /* prepare */
    CommandLineSettings settings = createSettingsMockWithNecessaryParts();
    when(settings.isAjaxSpiderEnabled()).thenReturn(enabled);
    /* execute */
    OwaspZapScanConfiguration result = factoryToTest.create(settings);
    /* test */
    assertEquals(result.isAjaxSpiderEnabled(), enabled);
}
Also used : CommandLineSettings(com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with CommandLineSettings

use of com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings in project sechub by mercedes-benz.

the class OwaspZapScanConfigurationFactoryTest method active_scan_enabled_from_settings_is_in_result.

@ParameterizedTest
@CsvSource({ "true", "false" })
void active_scan_enabled_from_settings_is_in_result(boolean enabled) {
    /* prepare */
    CommandLineSettings settings = createSettingsMockWithNecessaryParts();
    when(settings.isActiveScanEnabled()).thenReturn(enabled);
    /* execute */
    OwaspZapScanConfiguration result = factoryToTest.create(settings);
    /* test */
    assertEquals(result.isActiveScanEnabled(), enabled);
}
Also used : CommandLineSettings(com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with CommandLineSettings

use of com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings in project sechub by mercedes-benz.

the class OwaspZapScanConfigurationFactoryTest method configuration_returned_by_provider_is_inside_result.

@Test
void configuration_returned_by_provider_is_inside_result() {
    /* prepare */
    CommandLineSettings settings = createSettingsMockWithNecessaryParts();
    SecHubWebScanConfiguration config = simulateProvidedSecHubConfiguration(settings);
    /* execute */
    OwaspZapScanConfiguration result = factoryToTest.create(settings);
    /* test */
    assertEquals(result.getSecHubWebScanConfiguration(), config);
}
Also used : SecHubWebScanConfiguration(com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration) CommandLineSettings(com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with CommandLineSettings

use of com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings in project sechub by mercedes-benz.

the class OwaspZapScanConfigurationFactoryTest method result_contains_server_config_with_arguments_from_environment_when_command_line_settings_not_set.

@ParameterizedTest
@CsvSource({ "https://zaproxy.example.com,8080,api-key,https://proxy.example.com,3333", "host,4711,secret,proxy,5312" })
void result_contains_server_config_with_arguments_from_environment_when_command_line_settings_not_set(String host, int port, String apiKey, String proxy, int proxyPort) {
    /* prepare */
    CommandLineSettings settings = mock(CommandLineSettings.class);
    when(environmentVariableReader.readAsString(ZAP_HOST_ENV_VARIABLE_NAME)).thenReturn(host);
    when(environmentVariableReader.readAsString(ZAP_API_KEY_ENV_VARIABLE_NAME)).thenReturn(apiKey);
    when(environmentVariableReader.readAsInt(ZAP_PORT_ENV_VARIABLE_NAME)).thenReturn(port);
    when(environmentVariableReader.readAsString(PROXY_HOST_ENV_VARIABLE_NAME)).thenReturn(proxy);
    when(environmentVariableReader.readAsInt(PROXY_PORT_ENV_VARIABLE_NAME)).thenReturn(proxyPort);
    /* execute */
    OwaspZapScanConfiguration result = factoryToTest.create(settings);
    /* test */
    OwaspZapServerConfiguration serverConfig = result.getServerConfig();
    assertNotNull(serverConfig);
    assertEquals(host, serverConfig.getZaproxyHost());
    assertEquals(port, serverConfig.getZaproxyPort());
    assertEquals(apiKey, serverConfig.getZaproxyApiKey());
    assertEquals(proxy, result.getProxyInformation().getHost());
    assertEquals(proxyPort, result.getProxyInformation().getPort());
}
Also used : CommandLineSettings(com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

CommandLineSettings (com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings)15 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)14 Test (org.junit.jupiter.api.Test)8 CsvSource (org.junit.jupiter.params.provider.CsvSource)6 SecHubWebScanConfiguration (com.mercedesbenz.sechub.commons.model.SecHubWebScanConfiguration)3 AuthenticationType (com.mercedesbenz.sechub.owaspzapwrapper.config.auth.AuthenticationType)1 File (java.io.File)1 URI (java.net.URI)1 Path (java.nio.file.Path)1