use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole in project pentaho-kettle by pentaho.
the class UserRoleHelper method convertToPentahoProxyRole.
public static ProxyPentahoRole convertToPentahoProxyRole(IRole roleInfo) {
ProxyPentahoRole role = new ProxyPentahoRole();
role.setName(roleInfo.getName());
role.setDescription(roleInfo.getDescription());
return role;
}
use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole in project pentaho-kettle by pentaho.
the class UserRoleHelper method convertToListFromProxyPentahoDefaultRoles.
public static List<IRole> convertToListFromProxyPentahoDefaultRoles(UserRoleSecurityInfo info, IRoleSupportSecurityManager rsm) {
List<IRole> roleList = new ArrayList<IRole>();
List<ProxyPentahoRole> roles = info.getDefaultRoles();
List<UserToRoleAssignment> assignments = info.getAssignments();
for (ProxyPentahoRole role : roles) {
roleList.add(convertFromProxyPentahoRole(role, assignments, rsm));
}
return roleList;
}
use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole in project pentaho-platform by pentaho.
the class UserRoleWebServiceBase method testSetRoles.
@Test
public void testSetRoles() throws UserRoleException {
UserRoleDaoMock userRoleDao = PentahoSystem.get(UserRoleDaoMock.class, USER_ROLE_DAO_TXN, null);
IUserRoleWebService service = getUserRoleWebService();
mockUserAsAdmin(false);
ProxyPentahoUser userObj = new ProxyPentahoUser();
userObj.setName("test1");
ProxyPentahoRole[] rolesObj = new ProxyPentahoRole[1];
rolesObj[0] = new ProxyPentahoRole("testRole2");
try {
service.setRoles(userObj, rolesObj);
Assert.fail();
} catch (UserRoleException e) {
Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
}
mockUserAsAdmin(true);
userRoleDao.getUserRoles(null, "test1");
Assert.assertEquals("testRole1", userRoleDao.getUserRoles(null, "test1").get(0).getName());
service.setRoles(userObj, rolesObj);
Assert.assertEquals("testRole2", userRoleDao.getUserRoles(null, "test1").get(0).getName());
}
use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole in project pentaho-platform by pentaho.
the class UserRoleWebServiceBase method testGetRolesForUser.
@Test
public void testGetRolesForUser() throws UserRoleException {
IUserRoleWebService service = getUserRoleWebService();
mockUserAsAdmin(false);
ProxyPentahoUser userObj = new ProxyPentahoUser();
userObj.setName("test1");
try {
service.getRolesForUser(userObj);
Assert.fail();
} catch (UserRoleException e) {
Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
}
mockUserAsAdmin(true);
ProxyPentahoRole[] roles = service.getRolesForUser(userObj);
Assert.assertEquals(1, roles.length);
}
use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole in project pentaho-platform by pentaho.
the class UserRoleWebServiceBase method testUpdateRole.
@Test
public void testUpdateRole() throws UserRoleException {
UserRoleDaoMock userRoleDao = PentahoSystem.get(UserRoleDaoMock.class, USER_ROLE_DAO_TXN, null);
IUserRoleWebService service = getUserRoleWebService();
mockUserAsAdmin(false);
ProxyPentahoRole roleObj = new ProxyPentahoRole("testRole1");
roleObj.setDescription("testUpdateRoleObject");
List<String> usernames = new ArrayList<String>();
try {
service.updateRole("testRole1", "testUpdateRoleObject", usernames);
Assert.fail();
} catch (UserRoleException e) {
Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
}
mockUserAsAdmin(true);
Assert.assertEquals("test role", userRoleDao.getRole(null, "testRole1").getDescription());
service.updateRole("testRole1", "testUpdateRoleObject", usernames);
Assert.assertEquals("testUpdateRoleObject", userRoleDao.getRole(null, "testRole1").getDescription());
}
Aggregations