use of com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings in project sechub by mercedes-benz.
the class OwaspZapScanConfigurationFactoryTest method context_name_is_created_as_UUID_when_not_defined.
@Test
void context_name_is_created_as_UUID_when_not_defined() {
/* prepare */
CommandLineSettings settings = createSettingsMockWithNecessaryParts();
when(settings.getJobUUID()).thenReturn(null);
/* execute */
OwaspZapScanConfiguration result = factoryToTest.create(settings);
/* test */
String contextName = result.getContextName();
assertNotNull(contextName);
// just check it us a uuid... (otherwise exception)
UUID.fromString(contextName);
}
use of com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings in project sechub by mercedes-benz.
the class OwaspZapScanConfigurationFactoryTest method created_configuration_has_max_scan_duration_from_sechub_webconfig.
@Test
void created_configuration_has_max_scan_duration_from_sechub_webconfig() {
/* prepare */
CommandLineSettings settings = createSettingsMockWithNecessaryParts();
SecHubWebScanConfiguration config = simulateProvidedSecHubConfiguration(settings);
long maxScanDueration = 4711L;
when(sechubWebConfigHelper.fetchMaxScanDurationInMillis(config)).thenReturn(maxScanDueration);
/* execute */
OwaspZapScanConfiguration result = factoryToTest.create(settings);
/* test */
assertEquals(result.getMaxScanDurationInMillis(), maxScanDueration);
}
use of com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings in project sechub by mercedes-benz.
the class OwaspZapScanConfigurationFactoryTest method fails_when_host_port_or_apikey_not_in_commandline_and_also_not_in_env.
/* @formatter:off*/
@ParameterizedTest
@CsvSource({ "host,4711,", "host,,secret", ",4711,secret" })
/* @formatter:on*/
void fails_when_host_port_or_apikey_not_in_commandline_and_also_not_in_env(String host, Integer port, String apiKey) {
/* prepare */
CommandLineSettings settings = mock(CommandLineSettings.class);
when(settings.getZapHost()).thenReturn(host);
if (port != null) {
// when not defined in CSV, null is used. The mock does use int primitive,
// so we just do not set it.
when(settings.getZapPort()).thenReturn(port);
}
when(settings.getZapApiKey()).thenReturn(apiKey);
/* execute + test */
assertThrows(MustExitRuntimeException.class, () -> factoryToTest.create(settings));
}
use of com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings in project sechub by mercedes-benz.
the class OwaspZapScanConfigurationFactoryTest method proxy_set_or_not_is_valid_result_returned_contains_null_as_proxyinformation.
@Test
void proxy_set_or_not_is_valid_result_returned_contains_null_as_proxyinformation() {
/* prepare */
CommandLineSettings settings = createSettingsMockWithNecessaryParts();
when(settings.getProxyHost()).thenReturn(null);
when(settings.getProxyPort()).thenReturn(0);
when(environmentVariableReader.readAsString(PROXY_HOST_ENV_VARIABLE_NAME)).thenReturn(null);
when(environmentVariableReader.readAsInt(PROXY_PORT_ENV_VARIABLE_NAME)).thenReturn(0);
/* execute */
OwaspZapScanConfiguration result = factoryToTest.create(settings);
/* test */
assertNotNull(result);
assertNull(result.getProxyInformation());
}
use of com.mercedesbenz.sechub.owaspzapwrapper.cli.CommandLineSettings in project sechub by mercedes-benz.
the class OwaspZapScanConfigurationFactoryTest method context_name_is_used_from_settings_when_defined.
@Test
void context_name_is_used_from_settings_when_defined() {
/* prepare */
CommandLineSettings settings = createSettingsMockWithNecessaryParts();
String jobUUID = "12345";
when(settings.getJobUUID()).thenReturn(jobUUID);
/* execute */
OwaspZapScanConfiguration result = factoryToTest.create(settings);
/* test */
assertEquals(result.getContextName(), jobUUID);
}
Aggregations