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());
}
}
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());
}
}
Aggregations