use of org.pentaho.platform.security.userroledao.ws.UserRoleException 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());
}
use of org.pentaho.platform.security.userroledao.ws.UserRoleException 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());
}
use of org.pentaho.platform.security.userroledao.ws.UserRoleException in project pentaho-platform by pentaho.
the class UserRoleWebServiceBase method testDeleteRoles.
@Test
public void testDeleteRoles() throws Exception {
IUserRoleWebService service = getUserRoleWebService();
mockUserAsAdmin(false);
ProxyPentahoRole[] rolesObj = new ProxyPentahoRole[1];
rolesObj[0] = new ProxyPentahoRole("testRole1");
try {
service.deleteRoles(rolesObj);
Assert.fail();
} catch (UserRoleException e) {
Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
}
mockUserAsAdmin(true);
service.deleteRoles(rolesObj);
Assert.assertEquals(1, roles.size());
}
use of org.pentaho.platform.security.userroledao.ws.UserRoleException in project pentaho-platform by pentaho.
the class UserRoleWebServiceBase method testCreateBlankUser.
@Test
public void testCreateBlankUser() throws UserRoleException {
UserRoleWebService userRoleWebService = new UserRoleWebService();
ProxyPentahoUser proxyPentahoUser = new ProxyPentahoUser();
try {
userRoleWebService.createUser(proxyPentahoUser);
Assert.fail();
} catch (UserRoleException e) {
Assert.assertEquals(0, e.getStackTrace().length);
}
}
use of org.pentaho.platform.security.userroledao.ws.UserRoleException in project pentaho-platform by pentaho.
the class UserRoleWebServiceBase method testGetUserRoleSecurityInfo.
@Test
public void testGetUserRoleSecurityInfo() throws Exception {
IUserRoleWebService service = getUserRoleWebService();
mockUserAsAdmin(false);
try {
service.getUserRoleSecurityInfo();
Assert.fail();
} catch (UserRoleException e) {
// should this be 0001, not admin?
Assert.assertTrue(e.getMessage().indexOf("ERROR_0001") >= 0);
}
mockUserAsAdmin(true);
UserRoleSecurityInfo info = service.getUserRoleSecurityInfo();
Assert.assertNotNull(info);
Assert.assertEquals(2, info.getRoles().size());
Assert.assertEquals(2, info.getUsers().size());
Assert.assertEquals(2, info.getAssignments().size());
}
Aggregations