use of org.pentaho.platform.plugin.services.security.userrole.jdbc.JdbcUserRoleListService in project pentaho-platform by pentaho.
the class JdbcUserRoleListServiceTest method testGetRolesForUser.
@Test
public void testGetRolesForUser() throws Exception {
JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
dao.setUserDetailsService(makePopulatedJdbcDao());
dao.afterPropertiesSet();
// $NON-NLS-1$
List<String> roles = dao.getRolesForUser("rod");
// $NON-NLS-1$
assertTrue(roles.contains("ROLE_TELLER"));
// $NON-NLS-1$
assertTrue(roles.contains("ROLE_SUPERVISOR"));
}
use of org.pentaho.platform.plugin.services.security.userrole.jdbc.JdbcUserRoleListService in project pentaho-platform by pentaho.
the class JdbcUserRoleListServiceTest method testGetAllAuthoritiesForTenant.
@Test
public void testGetAllAuthoritiesForTenant() 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");
dao.afterPropertiesSet();
List<String> auths = dao.getAllRoles(defaultTenant);
// $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);
}
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 testGetAllUsernamesForTenant.
@Test
public void testGetAllUsernamesForTenant() throws Exception {
ITenant defaultTenant = new Tenant("/pentaho/tenant0", true);
login("admin", defaultTenant);
JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
// $NON-NLS-1$
dao.setAllUsernamesQuery("SELECT DISTINCT(USERNAME) FROM USERS ORDER BY USERNAME");
dao.afterPropertiesSet();
List<String> allUsers = dao.getAllUsers(defaultTenant);
// $NON-NLS-1$
assertTrue("User List should not be empty", allUsers.size() > 0);
for (String username : allUsers) {
// $NON-NLS-1$
System.out.println("User: " + username);
}
try {
allUsers = dao.getAllUsers(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 testGetAllUsernames.
@Test
public void testGetAllUsernames() throws Exception {
JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
// $NON-NLS-1$
dao.setAllUsernamesQuery("SELECT DISTINCT(USERNAME) FROM USERS ORDER BY USERNAME");
dao.afterPropertiesSet();
List<String> allUsers = dao.getAllUsers();
// $NON-NLS-1$
assertTrue("User List should not be empty", allUsers.size() > 0);
for (String username : allUsers) {
// $NON-NLS-1$
System.out.println("User: " + username);
}
}
use of org.pentaho.platform.plugin.services.security.userrole.jdbc.JdbcUserRoleListService in project pentaho-platform by pentaho.
the class JdbcUserRoleListServiceTest method testGetRolesForUserForTenant.
@Test
public void testGetRolesForUserForTenant() throws Exception {
ITenant defaultTenant = new Tenant("/pentaho/tenant0", true);
login("admin", defaultTenant);
JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
dao.setUserDetailsService(makePopulatedJdbcDao());
dao.afterPropertiesSet();
// $NON-NLS-1$
List<String> roles = dao.getRolesForUser(defaultTenant, "rod");
// $NON-NLS-1$
assertTrue(roles.contains("ROLE_TELLER"));
// $NON-NLS-1$
assertTrue(roles.contains("ROLE_SUPERVISOR"));
try {
roles = dao.getRolesForUser(new Tenant("/pentaho", true), "rod");
} catch (UnsupportedOperationException uoe) {
assertNotNull(uoe);
}
}
Aggregations