Search in sources :

Example 1 with MondrianOneToOneUserRoleListMapper

use of org.pentaho.platform.plugin.action.mondrian.mapper.MondrianOneToOneUserRoleListMapper in project pentaho-platform by pentaho.

the class UserRoleMapperIT method testMondrianOneToOneUserRoleListMapper.

@Test
public void testMondrianOneToOneUserRoleListMapper() throws Exception {
    final IConnectionUserRoleMapper mapper = new MondrianOneToOneUserRoleListMapper();
    try {
        String[] roles = SecurityHelper.getInstance().runAsUser("simplebob", new Callable<String[]>() {

            @Override
            public String[] call() throws Exception {
                return mapper.mapConnectionRoles(PentahoSessionHolder.getSession(), "SteelWheelsRoles");
            }
        });
        Assert.assertNotNull(roles);
        Assert.assertEquals(2, roles.length);
        Assert.assertEquals("Role1", roles[0]);
        Assert.assertEquals("Role2", roles[1]);
    } catch (PentahoAccessControlException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : IConnectionUserRoleMapper(org.pentaho.platform.api.engine.IConnectionUserRoleMapper) MondrianOneToOneUserRoleListMapper(org.pentaho.platform.plugin.action.mondrian.mapper.MondrianOneToOneUserRoleListMapper) PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException) UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException) PlatformInitializationException(org.pentaho.platform.engine.core.system.boot.PlatformInitializationException) DataAccessException(org.springframework.dao.DataAccessException) Test(org.junit.Test)

Example 2 with MondrianOneToOneUserRoleListMapper

use of org.pentaho.platform.plugin.action.mondrian.mapper.MondrianOneToOneUserRoleListMapper in project pentaho-platform by pentaho.

the class UserRoleMapperIT method testNoMatchMondrianOneToOneUserRoleListMapper.

@Test
public void testNoMatchMondrianOneToOneUserRoleListMapper() throws Exception {
    final MondrianOneToOneUserRoleListMapper mapper = new MondrianOneToOneUserRoleListMapper();
    mapper.setFailOnEmptyRoleList(true);
    try {
        SecurityHelper.getInstance().runAsUser("admin", new Callable<String[]>() {

            @Override
            public String[] call() throws Exception {
                return mapper.mapConnectionRoles(PentahoSessionHolder.getSession(), "SteelWheelsRoles");
            }
        });
        Assert.fail();
    } catch (PentahoAccessControlException e) {
    // No op.
    }
    mapper.setFailOnEmptyRoleList(false);
    try {
        String[] roles = SecurityHelper.getInstance().runAsUser("simplebob", new Callable<String[]>() {

            @Override
            public String[] call() throws Exception {
                return mapper.mapConnectionRoles(PentahoSessionHolder.getSession(), "SteelWheelsRoles");
            }
        });
        Assert.assertArrayEquals(new String[] { "Role1", "Role2" }, roles);
    } catch (PentahoAccessControlException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : MondrianOneToOneUserRoleListMapper(org.pentaho.platform.plugin.action.mondrian.mapper.MondrianOneToOneUserRoleListMapper) PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException) UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException) PlatformInitializationException(org.pentaho.platform.engine.core.system.boot.PlatformInitializationException) DataAccessException(org.springframework.dao.DataAccessException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 PentahoAccessControlException (org.pentaho.platform.api.engine.PentahoAccessControlException)2 PlatformInitializationException (org.pentaho.platform.engine.core.system.boot.PlatformInitializationException)2 MondrianOneToOneUserRoleListMapper (org.pentaho.platform.plugin.action.mondrian.mapper.MondrianOneToOneUserRoleListMapper)2 DataAccessException (org.springframework.dao.DataAccessException)2 UsernameNotFoundException (org.springframework.security.core.userdetails.UsernameNotFoundException)2 IConnectionUserRoleMapper (org.pentaho.platform.api.engine.IConnectionUserRoleMapper)1