use of com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings in project sechub by mercedes-benz.
the class OwaspZapScanConfigurationFactoryTest method targetURI_calculated_by_factory_is_in_result.
@Test
void targetURI_calculated_by_factory_is_in_result() {
/* prepare */
CommandLineSettings settings = createSettingsMockWithNecessaryParts();
String targetUri = "https://www.example.com";
when(settings.getTargetURL()).thenReturn(targetUri);
URI createdUri = URI.create("https://fromfactory.example.com");
when(targetUriFactory.create(targetUri)).thenReturn(createdUri);
/* execute */
OwaspZapScanConfiguration result = factoryToTest.create(settings);
/* test */
assertEquals(result.getTargetUri(), createdUri);
}
use of com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings in project sechub by mercedes-benz.
the class OwaspZapScanConfigurationFactoryTest method createSettingsMockWithNecessaryParts.
private CommandLineSettings createSettingsMockWithNecessaryParts() {
CommandLineSettings settings = mock(CommandLineSettings.class);
when(settings.getZapHost()).thenReturn("https://zaphot.example.com");
when(settings.getZapPort()).thenReturn(815);
when(settings.getZapApiKey()).thenReturn("secret-key");
return settings;
}
use of com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings in project sechub by mercedes-benz.
the class OwaspZapScanConfigurationFactoryTest method report_file_from_setting_is_used_in_result.
@Test
void report_file_from_setting_is_used_in_result() {
/* prepare */
CommandLineSettings settings = createSettingsMockWithNecessaryParts();
Path path = new File("not-existing").toPath();
when(settings.getReportFile()).thenReturn(path);
/* execute */
OwaspZapScanConfiguration result = factoryToTest.create(settings);
/* test */
assertEquals(result.getReportFile(), path);
}
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_command_line_settings_no_env_variables.
@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_command_line_settings_no_env_variables(String host, int port, String apiKey, String proxy, int proxyPort) {
/* prepare */
CommandLineSettings settings = createSettingsMockWithNecessaryParts();
when(settings.getZapHost()).thenReturn(host);
when(settings.getZapPort()).thenReturn(port);
when(settings.getZapApiKey()).thenReturn(apiKey);
when(settings.getProxyHost()).thenReturn(proxy);
when(settings.getProxyPort()).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());
verify(environmentVariableReader, never()).readAsInt(any());
verify(environmentVariableReader, never()).readAsString(any());
}
use of com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings in project sechub by mercedes-benz.
the class OwaspZapScanConfigurationFactoryTest method verbose_from_settings_is_in_result.
@ParameterizedTest
@CsvSource({ "true", "false" })
void verbose_from_settings_is_in_result(boolean verboseEnabled) {
/* prepare */
CommandLineSettings settings = createSettingsMockWithNecessaryParts();
when(settings.isVerboseEnabled()).thenReturn(verboseEnabled);
/* execute */
OwaspZapScanConfiguration result = factoryToTest.create(settings);
/* test */
assertEquals(result.isVerboseOutput(), verboseEnabled);
}
Aggregations