mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 08:55:44 +01:00
added DAORealmHelperFactory to simplify the creation of dao based realms
This commit is contained in:
@@ -48,10 +48,10 @@ import org.apache.shiro.realm.AuthenticatingRealm;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.group.GroupDAO;
|
||||
import sonia.scm.plugin.Extension;
|
||||
|
||||
import sonia.scm.security.DAORealmHelper;
|
||||
import sonia.scm.user.UserDAO;
|
||||
import sonia.scm.security.DAORealmHelperFactory;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -92,13 +92,12 @@ public class LegacyRealm extends AuthenticatingRealm
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param userDAO
|
||||
* @param groupDAO
|
||||
* @param helperFactory
|
||||
*/
|
||||
@Inject
|
||||
public LegacyRealm(UserDAO userDAO, GroupDAO groupDAO)
|
||||
public LegacyRealm(DAORealmHelperFactory helperFactory)
|
||||
{
|
||||
this.helper = new DAORealmHelper(REALM, userDAO, groupDAO);
|
||||
this.helper = helperFactory.create(REALM);
|
||||
setAuthenticationTokenClass(UsernamePasswordToken.class);
|
||||
|
||||
HashedCredentialsMatcher matcher = new HashedCredentialsMatcher();
|
||||
|
||||
@@ -54,8 +54,10 @@ import sonia.scm.user.UserDAO;
|
||||
import sonia.scm.user.UserTestData;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
import sonia.scm.security.DAORealmHelperFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -71,6 +73,14 @@ public class LegacyRealmTest
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Prepare object under test.
|
||||
*/
|
||||
@Before
|
||||
public void prepareObjectUnderTest() {
|
||||
this.realm = new LegacyRealm(helperFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -134,15 +144,15 @@ public class LegacyRealmTest
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
@Mock
|
||||
private UserDAO userDAO;
|
||||
|
||||
@Mock
|
||||
private GroupDAO groupDAO;
|
||||
|
||||
/** Field description */
|
||||
@InjectMocks
|
||||
private DAORealmHelperFactory helperFactory;
|
||||
|
||||
private LegacyRealm realm;
|
||||
|
||||
/** Field description */
|
||||
@Mock
|
||||
private UserDAO userDAO;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user