use of org.pentaho.platform.engine.security.DefaultUsernameComparator in project pentaho-platform by pentaho.
the class DefaultLdapUserRoleListServiceTest method testGetAllUserNames1Sorted.
/**
* Same as above except sorted.
*/
@Test
public void testGetAllUserNames1Sorted() throws Exception {
SearchControls con1 = new SearchControls();
// $NON-NLS-1$
con1.setReturningAttributes(new String[] { "uniqueMember" });
LdapSearchParamsFactoryImpl paramFactory = // $NON-NLS-1$//$NON-NLS-2$
new LdapSearchParamsFactoryImpl("ou=groups", "(objectClass=groupOfUniqueNames)", con1);
paramFactory.afterPropertiesSet();
// $NON-NLS-1$ //$NON-NLS-2$
Transformer transformer1 = new SearchResultToAttrValueList("uniqueMember", "uid");
GenericLdapSearch allUsernamesSearch = new GenericLdapSearch(getContextSource(), paramFactory, transformer1);
allUsernamesSearch.afterPropertiesSet();
DefaultLdapUserRoleListService userRoleListService = getDefaultLdapUserRoleListService();
userRoleListService.setAllUsernamesSearch(allUsernamesSearch);
userRoleListService.setUsernameComparator(new DefaultUsernameComparator());
List res = userRoleListService.getAllUsers();
assertTrue(res.indexOf("pat") < res.indexOf("tiffany"));
if (logger.isDebugEnabled()) {
// $NON-NLS-1$
logger.debug("results of getAllUserNames1Sorted(): " + res);
}
}
use of org.pentaho.platform.engine.security.DefaultUsernameComparator in project pentaho-platform by pentaho.
the class InMemoryUserRoleListServiceTest method testGetAllUserNamesSorted.
@Test
public void testGetAllUserNamesSorted() throws Exception {
dao.setUsernameComparator(new DefaultUsernameComparator());
List<String> usernames = dao.getAllUsers();
if (logger.isDebugEnabled()) {
// $NON-NLS-1$
logger.debug("testGetAllUserNamesSorted(): Usernames: " + usernames);
}
assertTrue(usernames.indexOf("marissa") < usernames.indexOf("scott"));
}
use of org.pentaho.platform.engine.security.DefaultUsernameComparator in project pentaho-platform by pentaho.
the class InMemoryUserRoleListServiceTest method testGetAllUserNamesInRoleSorted.
@Test
public void testGetAllUserNamesInRoleSorted() throws Exception {
dao.setUsernameComparator(new DefaultUsernameComparator());
List<String> usernames = dao.getUsersInRole(null, "ROLE_ONE");
if (logger.isDebugEnabled()) {
// $NON-NLS-1$
logger.debug("testGetAllUserNamesInRoleSorted(): Usernames: " + usernames);
}
assertTrue(usernames.indexOf("marissa") < usernames.indexOf("scott"));
}
use of org.pentaho.platform.engine.security.DefaultUsernameComparator in project pentaho-platform by pentaho.
the class DefaultLdapUserRoleListServiceTest method testGetUsernamesInRole1Sorted.
/**
* Same as above except sorted.
*/
@Test
public void testGetUsernamesInRole1Sorted() {
SearchControls con1 = new SearchControls();
// $NON-NLS-1$
con1.setReturningAttributes(new String[] { "uid" });
LdapSearchParamsFactory paramFactory = // $NON-NLS-1$//$NON-NLS-2$
new LdapSearchParamsFactoryImpl("ou=users", "(businessCategory=cn={0}*)", con1);
// $NON-NLS-1$
Transformer transformer1 = new SearchResultToAttrValueList("uid");
GrantedAuthorityToString transformer2 = new GrantedAuthorityToString();
LdapSearch usernamesInRoleSearch = new GenericLdapSearch(getContextSource(), paramFactory, transformer1, transformer2);
DefaultLdapUserRoleListService userRoleListService = getDefaultLdapUserRoleListService();
userRoleListService.setUsernamesInRoleSearch(usernamesInRoleSearch);
userRoleListService.setUsernameComparator(new DefaultUsernameComparator());
// $NON-NLS-1$
List<String> res = userRoleListService.getUsersInRole(null, "DEV");
// $NON-NLS-1$
assertTrue(res.contains("pat"));
// $NON-NLS-1$
assertTrue(res.contains("tiffany"));
assertTrue(res.indexOf("pat") < res.indexOf("tiffany"));
if (logger.isDebugEnabled()) {
// $NON-NLS-1$
logger.debug("results of getUsernamesInRole1Sorted(): " + res);
}
}
Aggregations