mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25:45 +01:00
This change allows us to implement NamespaceStrategies, such as by type (git, hg, svn) or manual defined. The DefaultNamespaceStrategy accepts now a predefined namespace and only if no namespace was set the username of the currently logged in user is used.
33 lines
953 B
Java
33 lines
953 B
Java
package sonia.scm.repository;
|
|
|
|
import com.github.sdorra.shiro.ShiroRule;
|
|
import com.github.sdorra.shiro.SubjectAware;
|
|
import org.junit.Rule;
|
|
import org.junit.Test;
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
@SubjectAware(configuration = "classpath:sonia/scm/shiro-001.ini")
|
|
public class DefaultNamespaceStrategyTest {
|
|
|
|
@Rule
|
|
public ShiroRule shiroRule = new ShiroRule();
|
|
|
|
private DefaultNamespaceStrategy namespaceStrategy = new DefaultNamespaceStrategy();
|
|
|
|
@Test
|
|
@SubjectAware(username = "trillian", password = "secret")
|
|
public void testNamespaceStrategyWithoutPreset() {
|
|
assertEquals("trillian", namespaceStrategy.createNamespace(new Repository()));
|
|
}
|
|
|
|
@Test
|
|
@SubjectAware(username = "trillian", password = "secret")
|
|
public void testNamespaceStrategyWithPreset() {
|
|
Repository repository = new Repository();
|
|
repository.setNamespace("awesome");
|
|
assertEquals("awesome", namespaceStrategy.createNamespace(repository));
|
|
}
|
|
|
|
}
|