Package org.pentaho.platform.plugin.services.security.userrole.jdbc

Examples of org.pentaho.platform.plugin.services.security.userrole.jdbc.JdbcUserRoleListService


public class JdbcUserRoleListServiceTests {

  @Test
  public void testGetAllUsernames() throws Exception {
    JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
    dao.setAllUsernamesQuery( "SELECT DISTINCT(USERNAME) FROM USERS ORDER BY USERNAME" ); //$NON-NLS-1$
    dao.afterPropertiesSet();
    List<String> allUsers = dao.getAllUsers();
    assertTrue( "User List should not be empty", allUsers.size() > 0 ); //$NON-NLS-1$
    for ( String username : allUsers ) {
      System.out.println( "User: " + username ); //$NON-NLS-1$
    }
  }
View Full Code Here


  @Test
  public void testGetAllUsernamesForTenant() throws Exception {
    ITenant defaultTenant = new Tenant( "/pentaho/tenant0", true );
    login( "admin", defaultTenant );
    JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
    dao.setAllUsernamesQuery( "SELECT DISTINCT(USERNAME) FROM USERS ORDER BY USERNAME" ); //$NON-NLS-1$
    dao.afterPropertiesSet();
    List<String> allUsers = dao.getAllUsers( defaultTenant );
    assertTrue( "User List should not be empty", allUsers.size() > 0 ); //$NON-NLS-1$
    for ( String username : allUsers ) {
      System.out.println( "User: " + username ); //$NON-NLS-1$
    }
    try {
      allUsers = dao.getAllUsers( new Tenant( "/pentaho", true ) );
    } catch ( UnsupportedOperationException uoe ) {
      assertNotNull( uoe );
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testGetAllAuthorities() throws Exception {
    JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
    dao.setAllAuthoritiesQuery( "SELECT DISTINCT(AUTHORITY) AS AUTHORITY FROM AUTHORITIES ORDER BY 1" ); //$NON-NLS-1$
    dao.afterPropertiesSet();
    List<String> auths = dao.getAllRoles();
    assertTrue( "Authorities list should not be empty", auths.size() > 0 ); //$NON-NLS-1$
    for ( String auth : auths ) {
      System.out.println( "Authority: " + auth ); //$NON-NLS-1$
    }
  }
View Full Code Here

  @Test
  public void testGetAllAuthoritiesForTenant() throws Exception {
    ITenant defaultTenant = new Tenant( "/pentaho/tenant0", true );
    login( "admin", defaultTenant );

    JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
    dao.setAllAuthoritiesQuery( "SELECT DISTINCT(AUTHORITY) AS AUTHORITY FROM AUTHORITIES ORDER BY 1" ); //$NON-NLS-1$
    dao.afterPropertiesSet();
    List<String> auths = dao.getAllRoles( defaultTenant );
    assertTrue( "Authorities list should not be empty", auths.size() > 0 ); //$NON-NLS-1$
    for ( String auth : auths ) {
      System.out.println( "Authority: " + auth ); //$NON-NLS-1$
    }

    try {
      auths = dao.getAllRoles( new Tenant( "/pentaho", true ) );
    } catch ( UnsupportedOperationException uoe ) {
      assertNotNull( uoe );
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testGetAllAuthoritiesWithRolePrefix() throws Exception {
    JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
    dao.setAllAuthoritiesQuery( "SELECT DISTINCT(AUTHORITY) AS AUTHORITY FROM AUTHORITIES ORDER BY 1" ); //$NON-NLS-1$
    dao.setRolePrefix( "ARBITRARY_PREFIX_" ); //$NON-NLS-1$
    dao.afterPropertiesSet();
    List<String> auths = dao.getAllRoles();
    assertTrue( "Authorities list should not be empty", auths.size() > 0 ); //$NON-NLS-1$
    for ( String role : auths ) {
      System.out.println( "Authority with prefix: " + role ); //$NON-NLS-1$
    }
  }
View Full Code Here

  @Test
  public void testGetAllAuthoritiesWithRolePrefixForTenant() throws Exception {
    ITenant defaultTenant = new Tenant( "/pentaho/tenant0", true );
    login( "admin", defaultTenant );
    JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
    dao.setAllAuthoritiesQuery( "SELECT DISTINCT(AUTHORITY) AS AUTHORITY FROM AUTHORITIES ORDER BY 1" ); //$NON-NLS-1$
    dao.setRolePrefix( "ARBITRARY_PREFIX_" ); //$NON-NLS-1$
    dao.afterPropertiesSet();
    List<String> auths = dao.getAllRoles( defaultTenant );
    assertTrue( "Authorities list should not be empty", auths.size() > 0 ); //$NON-NLS-1$
    for ( String role : auths ) {
      System.out.println( "Authority with prefix: " + role ); //$NON-NLS-1$
    }

    try {
      auths = dao.getAllRoles( new Tenant( "/pentaho", true ) );
    } catch ( UnsupportedOperationException uoe ) {
      assertNotNull( uoe );
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testGetAllUsernamesInRole() throws Exception {
    JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
    dao.setAllUsernamesInRoleQuery(
      "SELECT DISTINCT(USERNAME) AS USERNAME FROM AUTHORITIES WHERE AUTHORITY = ? ORDER BY 1" ); //$NON-NLS-1$
    dao.afterPropertiesSet();
    List<String> allUsers = dao.getUsersInRole( "ROLE_TELLER" ); //$NON-NLS-1$
    assertTrue( "User List should not be empty", allUsers.size() > 0 ); //$NON-NLS-1$
    for ( String username : allUsers ) {
      System.out.println( "ROLE_TELLER User: " + username ); //$NON-NLS-1$
    }
  }
View Full Code Here

  @Test
  public void testGetAllUsernamesInRoleForTenant() throws Exception {
    ITenant defaultTenant = new Tenant( "/pentaho/tenant0", true );
    login( "admin", defaultTenant );
    JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
    dao.setAllUsernamesInRoleQuery(
      "SELECT DISTINCT(USERNAME) AS USERNAME FROM AUTHORITIES WHERE AUTHORITY = ? ORDER BY 1" ); //$NON-NLS-1$
    dao.afterPropertiesSet();
    List<String> allUsers = dao.getUsersInRole( defaultTenant, "ROLE_TELLER" ); //$NON-NLS-1$
    assertTrue( "User List should not be empty", allUsers.size() > 0 ); //$NON-NLS-1$
    for ( String username : allUsers ) {
      System.out.println( "ROLE_TELLER User: " + username ); //$NON-NLS-1$
    }

    try {
      allUsers = dao.getUsersInRole( new Tenant( "/pentaho", true ), "ROLE_TELLER" );
    } catch ( UnsupportedOperationException uoe ) {
      assertNotNull( uoe );
    }

  }
View Full Code Here

  }

  @Test
  public void testGetRolesForUser() throws Exception {
    JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
    dao.setUserDetailsService( makePopulatedJdbcDao() );
    dao.afterPropertiesSet();
    List<String> roles = dao.getRolesForUser( "rod" ); //$NON-NLS-1$
    assertTrue( roles.contains( "ROLE_TELLER" ) ); //$NON-NLS-1$
    assertTrue( roles.contains( "ROLE_SUPERVISOR" ) ); //$NON-NLS-1$

  }
View Full Code Here

  @Test
  public void testGetRolesForUserForTenant() throws Exception {
    ITenant defaultTenant = new Tenant( "/pentaho/tenant0", true );
    login( "admin", defaultTenant );
    JdbcUserRoleListService dao = makePopulatedJdbcUserRoleListService();
    dao.setUserDetailsService( makePopulatedJdbcDao() );
    dao.afterPropertiesSet();
    List<String> roles = dao.getRolesForUser( defaultTenant, "rod" ); //$NON-NLS-1$
    assertTrue( roles.contains( "ROLE_TELLER" ) ); //$NON-NLS-1$
    assertTrue( roles.contains( "ROLE_SUPERVISOR" ) ); //$NON-NLS-1$

    try {
      roles = dao.getRolesForUser( new Tenant( "/pentaho", true ), "rod" );
    } catch ( UnsupportedOperationException uoe ) {
      assertNotNull( uoe );
    }
  }
View Full Code Here

TOP

Related Classes of org.pentaho.platform.plugin.services.security.userrole.jdbc.JdbcUserRoleListService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.