use of org.pentaho.platform.plugin.services.security.userrole.jdbc.JdbcUserRoleListService in project pentaho-platform by pentaho.
the class JdbcUserRoleListServiceTest method testGetAllAuthoritiesWithRolePrefixForTenant.
@Test
public void testGetAllAuthoritiesWithRolePrefixForTenant() throws Exception {
ITenant defaultTenant = new Tenant("/pentaho/tenant0", true);
login("admin", defaultTenant);
JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
// $NON-NLS-1$
dao.setAllAuthoritiesQuery("SELECT DISTINCT(AUTHORITY) AS AUTHORITY FROM AUTHORITIES ORDER BY 1");
// $NON-NLS-1$
dao.setRolePrefix("ARBITRARY_PREFIX_");
dao.afterPropertiesSet();
List<String> auths = dao.getAllRoles(defaultTenant);
// $NON-NLS-1$
assertTrue("Authorities list should not be empty", auths.size() > 0);
for (String role : auths) {
// $NON-NLS-1$
System.out.println("Authority with prefix: " + role);
}
try {
auths = dao.getAllRoles(new Tenant("/pentaho", true));
} catch (UnsupportedOperationException uoe) {
assertNotNull(uoe);
}
}
use of org.pentaho.platform.plugin.services.security.userrole.jdbc.JdbcUserRoleListService in project pentaho-platform by pentaho.
the class JdbcUserRoleListServiceTest method testGetAllUsernamesInRoleForTenant.
@Test
public void testGetAllUsernamesInRoleForTenant() throws Exception {
ITenant defaultTenant = new Tenant("/pentaho/tenant0", true);
login("admin", defaultTenant);
JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
dao.setAllUsernamesInRoleQuery(// $NON-NLS-1$
"SELECT DISTINCT(USERNAME) AS USERNAME FROM AUTHORITIES WHERE AUTHORITY = ? ORDER BY 1");
dao.afterPropertiesSet();
// $NON-NLS-1$
List<String> allUsers = dao.getUsersInRole(defaultTenant, "ROLE_TELLER");
// $NON-NLS-1$
assertTrue("User List should not be empty", allUsers.size() > 0);
for (String username : allUsers) {
// $NON-NLS-1$
System.out.println("ROLE_TELLER User: " + username);
}
try {
allUsers = dao.getUsersInRole(new Tenant("/pentaho", true), "ROLE_TELLER");
} catch (UnsupportedOperationException uoe) {
assertNotNull(uoe);
}
}
use of org.pentaho.platform.plugin.services.security.userrole.jdbc.JdbcUserRoleListService in project pentaho-platform by pentaho.
the class JdbcUserRoleListServiceTest method testGetAllUsernamesInRole.
@Test
public void testGetAllUsernamesInRole() throws Exception {
JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
dao.setAllUsernamesInRoleQuery(// $NON-NLS-1$
"SELECT DISTINCT(USERNAME) AS USERNAME FROM AUTHORITIES WHERE AUTHORITY = ? ORDER BY 1");
dao.afterPropertiesSet();
// $NON-NLS-1$
List<String> allUsers = dao.getUsersInRole("ROLE_TELLER");
// $NON-NLS-1$
assertTrue("User List should not be empty", allUsers.size() > 0);
for (String username : allUsers) {
// $NON-NLS-1$
System.out.println("ROLE_TELLER User: " + username);
}
}
use of org.pentaho.platform.plugin.services.security.userrole.jdbc.JdbcUserRoleListService in project pentaho-platform by pentaho.
the class JdbcUserRoleListServiceTest method testGetAllAuthorities.
@Test
public void testGetAllAuthorities() throws Exception {
JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
// $NON-NLS-1$
dao.setAllAuthoritiesQuery("SELECT DISTINCT(AUTHORITY) AS AUTHORITY FROM AUTHORITIES ORDER BY 1");
dao.afterPropertiesSet();
List<String> auths = dao.getAllRoles();
// $NON-NLS-1$
assertTrue("Authorities list should not be empty", auths.size() > 0);
for (String auth : auths) {
// $NON-NLS-1$
System.out.println("Authority: " + auth);
}
}
use of org.pentaho.platform.plugin.services.security.userrole.jdbc.JdbcUserRoleListService in project pentaho-platform by pentaho.
the class JdbcUserRoleListServiceTest method makePopulatedJdbcUserRoleListService.
protected JdbcUserRoleListService makePopulatedJdbcUserRoleListService() throws Exception {
List<String> systemRoles = new ArrayList<String>();
systemRoles.add("Admin");
JdbcUserRoleListService dao = new JdbcUserRoleListService(makePopulatedJdbcDao(), systemRoles);
dao.setDataSource(PopulatedDatabase.getDataSource());
return dao;
}
Aggregations