use of com.mercedesbenz.sechub.commons.model.login.WebLoginConfiguration in project sechub by mercedes-benz.
the class SecHubConfigurationTest method webscan_login_basic_json_has_webconfig_as_expected.
@Test
public void webscan_login_basic_json_has_webconfig_as_expected() throws Exception {
/* prepare */
String json = SharedKernelTestFileSupport.getTestfileSupport().loadTestFile("webscan/webscan_login_basic.json");
/* execute */
SecHubConfiguration result = SECHUB_CONFIG.fromJSON(json);
/* test */
Optional<SecHubWebScanConfiguration> webScanOption = result.getWebScan();
assertTrue("webscan config must be present", webScanOption.isPresent());
SecHubWebScanConfiguration secHubWebScanConfiguration = webScanOption.get();
Optional<WebLoginConfiguration> loginOption = secHubWebScanConfiguration.getLogin();
assertTrue("login config must be present", loginOption.isPresent());
WebLoginConfiguration loginConfiguration = loginOption.get();
assertEquals(new URL("https://productfailure.demo.example.org/login"), loginConfiguration.getUrl());
/*-- basic --*/
Optional<BasicLoginConfiguration> basic = loginConfiguration.getBasic();
assertTrue("basic login config must be present", basic.isPresent());
assertEquals("realm0", basic.get().getRealm().get());
assertEquals("user0", new String(basic.get().getUser()));
assertEquals("pwd0", new String(basic.get().getPassword()));
/*-- form --*/
Optional<FormLoginConfiguration> form = loginConfiguration.getForm();
assertFalse("form login config must NOT be present", form.isPresent());
}
use of com.mercedesbenz.sechub.commons.model.login.WebLoginConfiguration in project sechub by mercedes-benz.
the class WebConfigBuilderStrategy method configureImpl.
private <B extends AbstractWebScanAdapterConfigBuilder<B, C>, C extends AbstractWebScanAdapterConfig> void configureImpl(B configBuilder) {
/* check precondition : login configured */
SecHubConfiguration configuration = context.getConfiguration();
if (configuration == null) {
return;
}
Optional<SecHubWebScanConfiguration> webScan = configuration.getWebScan();
if (!webScan.isPresent()) {
return;
}
SecHubWebScanConfiguration webscanConfig = webScan.get();
configBuilder.setTargetURI(webscanConfig.getUri());
handleMaxScanDuration(configBuilder, webscanConfig);
handleIncludes(configBuilder, webscanConfig);
handleExcludes(configBuilder, webscanConfig);
/* ----------------------- LOGIN ----------------------- */
Optional<WebLoginConfiguration> loginOpt = webscanConfig.getLogin();
if (!loginOpt.isPresent()) {
return;
}
/* handle different web login configurations: */
WebLoginConfiguration loginConfiguration = loginOpt.get();
URL loginUrl = loginConfiguration.getUrl();
/* ------ BASIC --------- */
Optional<BasicLoginConfiguration> basic = loginConfiguration.getBasic();
if (basic.isPresent()) {
configureBasicAuth(configBuilder, loginUrl, basic.get());
return;
}
/* ------ FORM --------- */
Optional<FormLoginConfiguration> formLogin = loginConfiguration.getForm();
if (!formLogin.isPresent()) {
return;
}
FormLoginConfiguration formLoginConfig = formLogin.get();
/* ------ FORM:SCRIPT--------- */
if (formLoginConfig.getScript().isPresent()) {
configureScriptAuth(configBuilder, loginUrl, formLoginConfig.getScript().get());
}
}
Aggregations