Search in sources :

Example 1 with JdbcUserRoleListService

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"));
}
Also used : JdbcUserRoleListService(org.pentaho.platform.plugin.services.security.userrole.jdbc.JdbcUserRoleListService) Test(org.junit.Test)

Example 2 with JdbcUserRoleListService

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);
    }
}
Also used : ITenant(org.pentaho.platform.api.mt.ITenant) Tenant(org.pentaho.platform.core.mt.Tenant) ITenant(org.pentaho.platform.api.mt.ITenant) JdbcUserRoleListService(org.pentaho.platform.plugin.services.security.userrole.jdbc.JdbcUserRoleListService) Test(org.junit.Test)

Example 3 with JdbcUserRoleListService

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);
    }
}
Also used : ITenant(org.pentaho.platform.api.mt.ITenant) Tenant(org.pentaho.platform.core.mt.Tenant) ITenant(org.pentaho.platform.api.mt.ITenant) JdbcUserRoleListService(org.pentaho.platform.plugin.services.security.userrole.jdbc.JdbcUserRoleListService) Test(org.junit.Test)

Example 4 with JdbcUserRoleListService

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);
    }
}
Also used : JdbcUserRoleListService(org.pentaho.platform.plugin.services.security.userrole.jdbc.JdbcUserRoleListService) Test(org.junit.Test)

Example 5 with JdbcUserRoleListService

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);
    }
}
Also used : ITenant(org.pentaho.platform.api.mt.ITenant) Tenant(org.pentaho.platform.core.mt.Tenant) ITenant(org.pentaho.platform.api.mt.ITenant) JdbcUserRoleListService(org.pentaho.platform.plugin.services.security.userrole.jdbc.JdbcUserRoleListService) Test(org.junit.Test)

Aggregations

JdbcUserRoleListService (org.pentaho.platform.plugin.services.security.userrole.jdbc.JdbcUserRoleListService)11 Test (org.junit.Test)10 ITenant (org.pentaho.platform.api.mt.ITenant)5 Tenant (org.pentaho.platform.core.mt.Tenant)5 ArrayList (java.util.ArrayList)1