use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser in project pentaho-platform by pentaho.
the class UserRoleWebServiceBase method testSetUsers.
@Test
public void testSetUsers() throws UserRoleException {
UserRoleDaoMock userRoleDao = PentahoSystem.get(UserRoleDaoMock.class, USER_ROLE_DAO_TXN, null);
IUserRoleWebService service = getUserRoleWebService();
mockUserAsAdmin(false);
ProxyPentahoRole roleObj = new ProxyPentahoRole("testRole1");
ProxyPentahoUser[] usersObj = new ProxyPentahoUser[1];
usersObj[0] = new ProxyPentahoUser();
usersObj[0].setName("test2");
try {
service.setUsers(roleObj, usersObj);
Assert.fail();
} catch (UserRoleException e) {
Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
}
mockUserAsAdmin(true);
Assert.assertEquals("test1", userRoleDao.getRoleMembers(null, "testRole1").get(0).getUsername());
service.setUsers(roleObj, usersObj);
Assert.assertEquals("test2", userRoleDao.getRoleMembers(null, "testRole1").get(0).getUsername());
}
use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser 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());
}
use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser in project pentaho-platform by pentaho.
the class UserRoleWebServiceBase method testGetUser.
@Test
public void testGetUser() throws Exception {
IUserRoleWebService service = getUserRoleWebService();
mockUserAsAdmin(false);
try {
service.getUser(null);
Assert.fail();
} catch (UserRoleException e) {
Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
}
mockUserAsAdmin(true);
ProxyPentahoUser userObj = service.getUser("test1");
Assert.assertNotNull(userObj);
Assert.assertEquals("test1", userObj.getName());
}
use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser in project pentaho-platform by pentaho.
the class UserRoleWebServiceBase method testCreateDuplicateUser.
@Test
public void testCreateDuplicateUser() throws UserRoleException {
UserRoleDaoMock userRoleDao = Mockito.mock(UserRoleDaoMock.class);
Mockito.doThrow(new AlreadyExistsException("That user name already exists.")).when(userRoleDao).createUser(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
UserRoleWebService userRoleWebService = new UserRoleWebService() {
@Override
protected IUserRoleDao getDao() throws UserRoleException {
return userRoleDao;
}
};
ProxyPentahoUser proxyPentahoUser = new ProxyPentahoUser();
proxyPentahoUser.setName("test");
proxyPentahoUser.setEnabled(true);
proxyPentahoUser.setPassword("test");
proxyPentahoUser.setDescription("testing");
try {
userRoleWebService.createUser(proxyPentahoUser);
Assert.fail();
} catch (AlreadyExistsException e) {
Assert.assertEquals(0, e.getStackTrace().length);
}
}
Aggregations