use of org.pentaho.platform.security.userroledao.ws.UserRoleException in project pentaho-platform by pentaho.
the class UserRoleWebServiceBase method testGetUsers.
@Test
public void testGetUsers() throws Exception {
IUserRoleWebService service = getUserRoleWebService();
mockUserAsAdmin(false);
try {
service.getUsers();
Assert.fail();
} catch (UserRoleException e) {
// should this be 0001, not admin?
Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
}
mockUserAsAdmin(true);
ProxyPentahoUser[] userObjs = service.getUsers();
Assert.assertNotNull(userObjs);
Assert.assertEquals(2, userObjs.length);
}
use of org.pentaho.platform.security.userroledao.ws.UserRoleException in project pentaho-platform by pentaho.
the class UserRoleWebServiceBase method testCreateUser.
@Test
public void testCreateUser() throws Exception {
UserRoleDaoMock userRoleDao = PentahoSystem.get(UserRoleDaoMock.class, USER_ROLE_DAO_TXN, null);
IUserRoleWebService service = getUserRoleWebService();
mockUserAsAdmin(false);
ProxyPentahoUser user = new ProxyPentahoUser();
user.setName("test");
user.setEnabled(true);
user.setPassword("test");
user.setDescription("testing");
try {
service.createUser(user);
Assert.fail();
} catch (UserRoleException e) {
Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
}
mockUserAsAdmin(true);
service.createUser(user);
// the last role should have the same name and description
IPentahoUser userVerified = userRoleDao.getUser(null, "test");
Assert.assertNotNull(userVerified);
Assert.assertEquals("test", userVerified.getUsername());
Assert.assertEquals("test", userVerified.getPassword());
Assert.assertEquals(true, userVerified.isEnabled());
Assert.assertEquals("testing", userVerified.getDescription());
}
use of org.pentaho.platform.security.userroledao.ws.UserRoleException in project pentaho-kettle by pentaho.
the class UserRoleHelper method convertFromProxyPentahoUser.
public static IUser convertFromProxyPentahoUser(IUserRoleWebService userRoleWebService, ProxyPentahoUser user, UserRoleLookupCache lookupCache, IRoleSupportSecurityManager rsm) {
IUser userInfo = null;
try {
userInfo = rsm.constructUser();
userInfo.setDescription(user.getDescription());
userInfo.setPassword(user.getPassword());
userInfo.setLogin(user.getName());
userInfo.setName(user.getName());
try {
if (userInfo instanceof IEEUser) {
((IEEUser) userInfo).setRoles(convertToSetFromProxyPentahoRoles(userRoleWebService.getRolesForUser(user), lookupCache));
}
} catch (UserRoleException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (KettleException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return userInfo;
}
use of org.pentaho.platform.security.userroledao.ws.UserRoleException in project pentaho-platform by pentaho.
the class UserRoleWebServiceBase method testGetUsersForRole.
@Test
public void testGetUsersForRole() throws UserRoleException {
IUserRoleWebService service = getUserRoleWebService();
mockUserAsAdmin(false);
ProxyPentahoRole roleObj = new ProxyPentahoRole("testRole1");
try {
service.getUsersForRole(roleObj);
Assert.fail();
} catch (UserRoleException e) {
Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
}
mockUserAsAdmin(true);
ProxyPentahoUser[] userObjs = service.getUsersForRole(roleObj);
Assert.assertEquals(1, userObjs.length);
}
use of org.pentaho.platform.security.userroledao.ws.UserRoleException in project pentaho-platform by pentaho.
the class UserRoleWebServiceBase method testUpdateRoleObject.
@Test
public void testUpdateRoleObject() 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");
try {
service.updateRoleObject(roleObj);
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.updateRoleObject(roleObj);
Assert.assertEquals("testUpdateRoleObject", userRoleDao.getRole(null, "testRole1").getDescription());
}
Aggregations