use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser in project pentaho-kettle by pentaho.
the class UserRoleHelper method convertToPentahoProxyUser.
public static ProxyPentahoUser convertToPentahoProxyUser(IUser userInfo) {
ProxyPentahoUser user = new ProxyPentahoUser();
user.setName(userInfo.getLogin());
// Since we send the empty password to the client, if the client has not modified the password then we do change it
if (!StringUtils.isEmpty(userInfo.getPassword())) {
user.setPassword(userInfo.getPassword());
}
user.setDescription(userInfo.getDescription());
return user;
}
use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser in project pentaho-kettle by pentaho.
the class UserRoleHelper method convertFromProxyPentahoUsers.
/* EESOURCE: UPDATE SERIALVERUID */
public static List<IUser> convertFromProxyPentahoUsers(UserRoleSecurityInfo info, IRoleSupportSecurityManager rsm) {
List<ProxyPentahoUser> users = info.getUsers();
if (users == null || users.isEmpty()) {
return Collections.emptyList();
}
List<UserToRoleAssignment> assignments = info.getAssignments();
List<IUser> userList = new ArrayList<IUser>(users.size());
for (ProxyPentahoUser user : users) {
userList.add(convertFromProxyPentahoUser(user, assignments, rsm));
}
return userList;
}
use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser 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.ProxyPentahoUser 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.ProxyPentahoUser in project pentaho-platform by pentaho.
the class UserRoleWebServiceBase method testUpdateUser.
@Test
public void testUpdateUser() 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");
userObj.setDescription("testUpdateUser");
userObj.setPassword("newpass");
try {
service.updateUser(userObj);
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", userRoleDao.getUser(null, "test1").getDescription());
service.updateUser(userObj);
Assert.assertEquals("testUpdateUser", userRoleDao.getUser(null, "test1").getDescription());
}
Aggregations