mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 07:55:47 +01:00
use shiro-unit for manager permission tests
This commit is contained in:
@@ -33,6 +33,13 @@
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import sonia.scm.util.MockUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -40,10 +47,28 @@ package sonia.scm;
|
||||
* @param <T>
|
||||
* @param <E>
|
||||
*/
|
||||
public abstract class ManagerTestBase<T extends ModelObject,
|
||||
E extends Exception> extends AbstractTestBase
|
||||
public abstract class ManagerTestBase<T extends ModelObject, E extends Exception>
|
||||
{
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder tempFolder = new TemporaryFolder();
|
||||
|
||||
protected SCMContextProvider contextProvider;
|
||||
|
||||
protected Manager<T, E> manager;
|
||||
|
||||
@Before
|
||||
public void setUp() throws IOException {
|
||||
contextProvider = MockUtil.getSCMContextProvider(tempFolder.newFolder());
|
||||
manager = createManager();
|
||||
manager.init(contextProvider);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws IOException {
|
||||
manager.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -52,33 +77,4 @@ public abstract class ManagerTestBase<T extends ModelObject,
|
||||
*/
|
||||
protected abstract Manager<T, E> createManager();
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
protected void postSetUp() throws Exception
|
||||
{
|
||||
manager = createManager();
|
||||
manager.init(contextProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
protected void preTearDown() throws Exception
|
||||
{
|
||||
manager.close();
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
protected Manager<T, E> manager;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ package sonia.scm.repository;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.github.legman.Subscribe;
|
||||
import com.github.sdorra.shiro.SubjectAware;
|
||||
|
||||
import org.apache.shiro.subject.Subject;
|
||||
|
||||
@@ -47,7 +48,6 @@ import sonia.scm.Manager;
|
||||
import sonia.scm.ManagerTestBase;
|
||||
import sonia.scm.event.ScmEventBus;
|
||||
import sonia.scm.repository.api.HookContext;
|
||||
import sonia.scm.util.MockUtil;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@@ -61,8 +61,7 @@ import java.util.Collection;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public abstract class RepositoryManagerTestBase
|
||||
extends ManagerTestBase<Repository, RepositoryException>
|
||||
public abstract class RepositoryManagerTestBase extends ManagerTestBase<Repository, RepositoryException>
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -378,19 +377,6 @@ public abstract class RepositoryManagerTestBase
|
||||
assertEquals(2, hook.eventsReceived);
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
@Before
|
||||
public void setAdminSubject()
|
||||
{
|
||||
Subject admin = MockUtil.createAdminSubject();
|
||||
|
||||
setSubject(admin);
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user