Search in sources :

Example 1 with MondrianUserSessionUserRoleListMapper

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

the class UserRoleMapperIT method testMondrianUserSessionUserRoleListMapper.

@Test
public void testMondrianUserSessionUserRoleListMapper() throws Exception {
    final MondrianUserSessionUserRoleListMapper mapper = new MondrianUserSessionUserRoleListMapper();
    mapper.setSessionProperty("rolesAttribute");
    try {
        String[] roles = SecurityHelper.getInstance().runAsUser("admin", new Callable<String[]>() {

            @Override
            public String[] call() throws Exception {
                IPentahoSession session = PentahoSessionHolder.getSession();
                session.setAttribute("rolesAttribute", new Object[] { "mondrianRole1", "mondrianRole2", "mondrianRole3" });
                return mapper.mapConnectionRoles(session, "SteelWheelsRoles");
            }
        });
        Assert.assertNotNull(roles);
        Assert.assertEquals(3, roles.length);
        Assert.assertEquals("mondrianRole1", roles[0]);
        Assert.assertEquals("mondrianRole2", roles[1]);
        Assert.assertEquals("mondrianRole3", roles[2]);
    } catch (PentahoAccessControlException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException) MondrianUserSessionUserRoleListMapper(org.pentaho.platform.plugin.action.mondrian.mapper.MondrianUserSessionUserRoleListMapper) 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 MondrianUserSessionUserRoleListMapper

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

the class UserRoleMapperIT method testNoMatchMondrianUserSessionUserRoleListMapper.

@Test
public void testNoMatchMondrianUserSessionUserRoleListMapper() throws Exception {
    final MondrianUserSessionUserRoleListMapper mapper = new MondrianUserSessionUserRoleListMapper();
    mapper.setSessionProperty("rolesAttribute");
    try {
        String[] roles = SecurityHelper.getInstance().runAsUser("admin", new Callable<String[]>() {

            @Override
            public String[] call() throws Exception {
                return mapper.mapConnectionRoles(PentahoSessionHolder.getSession(), "SteelWheelsRoles");
            }
        });
        Assert.assertNull(roles);
    } catch (PentahoAccessControlException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException) MondrianUserSessionUserRoleListMapper(org.pentaho.platform.plugin.action.mondrian.mapper.MondrianUserSessionUserRoleListMapper) 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 MondrianUserSessionUserRoleListMapper (org.pentaho.platform.plugin.action.mondrian.mapper.MondrianUserSessionUserRoleListMapper)2 DataAccessException (org.springframework.dao.DataAccessException)2 UsernameNotFoundException (org.springframework.security.core.userdetails.UsernameNotFoundException)2 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)1