use of org.pentaho.platform.security.userroledao.ws.IUserRoleWebService 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.IUserRoleWebService 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.IUserRoleWebService 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.IUserRoleWebService in project pentaho-platform by pentaho.
the class UserRoleWebServiceBase method testGetRoles.
@Test
public void testGetRoles() throws Exception {
IUserRoleWebService service = getUserRoleWebService();
mockUserAsAdmin(false);
try {
service.getRoles();
Assert.fail();
} catch (UserRoleException e) {
Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
}
mockUserAsAdmin(true);
ProxyPentahoRole[] roleObjs = service.getRoles();
Assert.assertNotNull(roleObjs);
Assert.assertEquals(2, roleObjs.length);
}
use of org.pentaho.platform.security.userroledao.ws.IUserRoleWebService in project pentaho-platform by pentaho.
the class UserRoleWebServiceBase method testDeleteUsers.
@Test
public void testDeleteUsers() throws Exception {
IUserRoleWebService service = getUserRoleWebService();
mockUserAsAdmin(false);
ProxyPentahoUser[] usersObj = new ProxyPentahoUser[1];
usersObj[0] = new ProxyPentahoUser();
usersObj[0].setName("test1");
try {
service.deleteUsers(usersObj);
Assert.fail();
} catch (UserRoleException e) {
Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
}
mockUserAsAdmin(true);
service.deleteUsers(usersObj);
Assert.assertEquals(1, users.size());
}
Aggregations