use of org.pentaho.platform.security.userroledao.ws.IUserRoleWebService 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());
}
use of org.pentaho.platform.security.userroledao.ws.IUserRoleWebService 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.IUserRoleWebService 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.IUserRoleWebService 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.IUserRoleWebService 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());
}
Aggregations