mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 17:26:22 +01:00
added configuration option for login info url
This commit is contained in:
@@ -50,6 +50,7 @@ public class ConfigDtoToScmConfigurationMapperTest {
|
||||
assertEquals(40 , config.getLoginAttemptLimitTimeout());
|
||||
assertTrue(config.isEnabledXsrfProtection());
|
||||
assertEquals("username", config.getNamespaceStrategy());
|
||||
assertEquals("https://scm-manager.org/login-info", config.getLoginInfoUrl());
|
||||
}
|
||||
|
||||
private ConfigDto createDefaultDto() {
|
||||
@@ -73,6 +74,7 @@ public class ConfigDtoToScmConfigurationMapperTest {
|
||||
configDto.setLoginAttemptLimitTimeout(40);
|
||||
configDto.setEnabledXsrfProtection(true);
|
||||
configDto.setNamespaceStrategy("username");
|
||||
configDto.setLoginInfoUrl("https://scm-manager.org/login-info");
|
||||
|
||||
return configDto;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,11 @@ package sonia.scm.api.v2.resources;
|
||||
import com.github.sdorra.shiro.ShiroRule;
|
||||
import com.github.sdorra.shiro.SubjectAware;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import sonia.scm.SCMContextProvider;
|
||||
import sonia.scm.config.ScmConfiguration;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Optional;
|
||||
@@ -19,9 +21,22 @@ public class IndexResourceTest {
|
||||
@Rule
|
||||
public final ShiroRule shiroRule = new ShiroRule();
|
||||
|
||||
private final SCMContextProvider scmContextProvider = mock(SCMContextProvider.class);
|
||||
private final IndexDtoGenerator indexDtoGenerator = new IndexDtoGenerator(ResourceLinksMock.createMock(URI.create("/")), scmContextProvider);
|
||||
private final IndexResource indexResource = new IndexResource(indexDtoGenerator);
|
||||
private ScmConfiguration configuration;
|
||||
private SCMContextProvider scmContextProvider;
|
||||
private IndexResource indexResource;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUpObjectUnderTest() {
|
||||
this.configuration = new ScmConfiguration();
|
||||
this.scmContextProvider = mock(SCMContextProvider.class);
|
||||
IndexDtoGenerator generator = new IndexDtoGenerator(
|
||||
ResourceLinksMock.createMock(URI.create("/")),
|
||||
scmContextProvider,
|
||||
configuration
|
||||
);
|
||||
this.indexResource = new IndexResource(generator);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldRenderLoginUrlsForUnauthenticatedRequest() {
|
||||
@@ -30,6 +45,22 @@ public class IndexResourceTest {
|
||||
Assertions.assertThat(index.getLinks().getLinkBy("login")).matches(Optional::isPresent);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldRenderLoginInfoUrl() {
|
||||
IndexDto index = indexResource.getIndex();
|
||||
|
||||
Assertions.assertThat(index.getLinks().getLinkBy("loginInfo")).isPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotRenderLoginInfoUrlWhenNoUrlIsConfigured() {
|
||||
configuration.setLoginInfoUrl("");
|
||||
|
||||
IndexDto index = indexResource.getIndex();
|
||||
|
||||
Assertions.assertThat(index.getLinks().getLinkBy("loginInfo")).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldRenderSelfLinkForUnauthenticatedRequest() {
|
||||
IndexDto index = indexResource.getIndex();
|
||||
|
||||
@@ -80,6 +80,7 @@ public class ScmConfigurationToConfigDtoMapperTest {
|
||||
assertEquals(2 , dto.getLoginAttemptLimitTimeout());
|
||||
assertTrue(dto.isEnabledXsrfProtection());
|
||||
assertEquals("username", dto.getNamespaceStrategy());
|
||||
assertEquals("https://scm-manager.org/login-info", dto.getLoginInfoUrl());
|
||||
|
||||
assertEquals(expectedBaseUri.toString(), dto.getLinks().getLinkBy("self").get().getHref());
|
||||
assertEquals(expectedBaseUri.toString(), dto.getLinks().getLinkBy("update").get().getHref());
|
||||
@@ -118,6 +119,7 @@ public class ScmConfigurationToConfigDtoMapperTest {
|
||||
config.setLoginAttemptLimitTimeout(2);
|
||||
config.setEnabledXsrfProtection(true);
|
||||
config.setNamespaceStrategy("username");
|
||||
config.setLoginInfoUrl("https://scm-manager.org/login-info");
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user