mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 08:25:44 +01:00
Config DTO: Adds namespace strategy
This commit is contained in:
@@ -33,6 +33,7 @@ public class ConfigDto extends HalRepresentation {
|
||||
private String pluginUrl;
|
||||
private long loginAttemptLimitTimeout;
|
||||
private boolean enabledXsrfProtection;
|
||||
private String defaultNamespaceStrategy;
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("squid:S1185") // We want to have this method available in this package
|
||||
|
||||
@@ -3,6 +3,7 @@ package sonia.scm.api.v2.resources;
|
||||
import de.otto.edison.hal.Links;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import sonia.scm.config.ConfigurationPermissions;
|
||||
import sonia.scm.config.ScmConfiguration;
|
||||
@@ -20,6 +21,7 @@ public abstract class ScmConfigurationToConfigDtoMapper {
|
||||
@Inject
|
||||
private ResourceLinks resourceLinks;
|
||||
|
||||
@Mapping(target = "attributes", ignore = true) // We do not map HAL attributes
|
||||
public abstract ConfigDto map(ScmConfiguration config);
|
||||
|
||||
@AfterMapping
|
||||
|
||||
@@ -51,6 +51,7 @@ public class ConfigDtoToScmConfigurationMapperTest {
|
||||
assertEquals("https://plug.ins" , config.getPluginUrl());
|
||||
assertEquals(40 , config.getLoginAttemptLimitTimeout());
|
||||
assertTrue(config.isEnabledXsrfProtection());
|
||||
assertEquals("username", config.getDefaultNamespaceStrategy());
|
||||
}
|
||||
|
||||
private ConfigDto createDefaultDto() {
|
||||
@@ -75,6 +76,7 @@ public class ConfigDtoToScmConfigurationMapperTest {
|
||||
configDto.setPluginUrl("https://plug.ins");
|
||||
configDto.setLoginAttemptLimitTimeout(40);
|
||||
configDto.setEnabledXsrfProtection(true);
|
||||
configDto.setDefaultNamespaceStrategy("username");
|
||||
|
||||
return configDto;
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ public class ScmConfigurationToConfigDtoMapperTest {
|
||||
assertEquals("pluginurl" , dto.getPluginUrl());
|
||||
assertEquals(2 , dto.getLoginAttemptLimitTimeout());
|
||||
assertTrue(dto.isEnabledXsrfProtection());
|
||||
assertEquals("username", dto.getDefaultNamespaceStrategy());
|
||||
|
||||
assertEquals(expectedBaseUri.toString(), dto.getLinks().getLinkBy("self").get().getHref());
|
||||
assertEquals(expectedBaseUri.toString(), dto.getLinks().getLinkBy("update").get().getHref());
|
||||
@@ -120,6 +121,7 @@ public class ScmConfigurationToConfigDtoMapperTest {
|
||||
config.setPluginUrl("pluginurl");
|
||||
config.setLoginAttemptLimitTimeout(2);
|
||||
config.setEnabledXsrfProtection(true);
|
||||
config.setDefaultNamespaceStrategy("username");
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user