mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 16:05:44 +01:00
mark security context as deprecated and use shiro apis instead
This commit is contained in:
@@ -38,6 +38,7 @@ package sonia.scm.util;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
import org.apache.shiro.authz.Permission;
|
||||
import org.apache.shiro.subject.PrincipalCollection;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
@@ -67,6 +68,12 @@ import javax.servlet.http.HttpServletResponse;
|
||||
public class MockUtil
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final User ADMIN = new User("scmadmin", "SCM Admin",
|
||||
"scmadmin@scm.org");
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -101,6 +108,14 @@ public class MockUtil
|
||||
when(subject.isPermittedAll()).thenReturn(Boolean.TRUE);
|
||||
when(subject.hasRole("admin")).thenReturn(Boolean.TRUE);
|
||||
|
||||
PrincipalCollection collection = mock(PrincipalCollection.class);
|
||||
|
||||
when(collection.getPrimaryPrincipal()).thenReturn(ADMIN.getId());
|
||||
when(collection.oneByType(User.class)).thenReturn(ADMIN);
|
||||
|
||||
when(subject.getPrincipal()).thenReturn(ADMIN.getId());
|
||||
when(subject.getPrincipals()).thenReturn(collection);
|
||||
|
||||
return subject;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user