use of org.activityinfo.shared.command.GetUsers in project activityinfo by bedatadriven.
the class GetUsersTest method testManageAllUsersPermission.
@Test
public void testManageAllUsersPermission() throws CommandException {
// Bavon from NRC(with manageAllUsers) permission
setUser(2);
// execute
UserResult result = execute(new GetUsers(1));
// VERIFY that we can get can see the two other users from NRC
Assert.assertEquals("number of results", 2, result.getTotalLength());
}
use of org.activityinfo.shared.command.GetUsers in project activityinfo by bedatadriven.
the class UpdateUserPermissionsHandlerTest method testOwnerUpdate.
/**
* Verifies that the owner of a database can update an existing users permission
*
* @throws CommandException
*/
@Test
@OnDataSet("/dbunit/schema1.db.xml")
public void testOwnerUpdate() throws CommandException {
setUser(1);
UserPermissionDTO user = new UserPermissionDTO();
user.setEmail("bavon@nrcdrc.org");
user.setPartner(new PartnerDTO(1, "NRC"));
user.setAllowView(true);
user.setAllowViewAll(false);
user.setAllowEdit(true);
user.setAllowEdit(false);
user.setAllowDesign(true);
execute(new UpdateUserPermissions(1, user));
UserResult result = execute(new GetUsers(1));
UserPermissionDTO reUser = result.getData().get(0);
Assert.assertEquals("bavon@nrcdrc.org", reUser.getEmail());
Assert.assertTrue("design rights", user.getAllowDesign());
}
use of org.activityinfo.shared.command.GetUsers in project activityinfo by bedatadriven.
the class ExportUsersServlet method doGet.
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
int dbId = Integer.valueOf(req.getParameter("dbUsers"));
try {
UserResult userResult = dispatcher.execute(new GetUsers(dbId));
DbUserExport export = new DbUserExport(userResult.getData());
export.createSheet();
resp.setContentType("application/vnd.ms-excel");
if (req.getHeader("User-Agent").indexOf("MSIE") != -1) {
resp.addHeader("Content-Disposition", "attachment; filename=ActivityInfo.xls");
} else {
resp.addHeader("Content-Disposition", "attachment; filename=" + ("ActivityInfo Export " + new Date().toString() + ".xls").replace(" ", "_"));
}
OutputStream os = resp.getOutputStream();
export.getBook().write(os);
} catch (Exception e) {
e.printStackTrace();
resp.setStatus(500);
}
}
use of org.activityinfo.shared.command.GetUsers in project activityinfo by bedatadriven.
the class GetUsersTest method testUnsorted.
@Test
public void testUnsorted() throws CommandException {
setUser(DATABASE_OWNER);
GetUsers cmd = new GetUsers(1);
UserResult result = execute(cmd);
Assert.assertEquals(3, result.getData().size());
}
use of org.activityinfo.shared.command.GetUsers in project activityinfo by bedatadriven.
the class GetUsersTest method testManageUsersPermission.
/**
* Verify that users with ManageUsers permission can get a list of users
* within their organisation
*/
@Test
public void testManageUsersPermission() throws CommandException {
// populate with a known state and authenticate as user 3, who
// has ManageUser permissions for Solidarites
// Lisa from Solidarites
setUser(3);
// execute
UserResult result = execute(new GetUsers(1));
// VERIFY that we have 1 result:
// - the one other solidarites user
Assert.assertEquals("number of results", 1, result.getTotalLength());
Assert.assertEquals("user name", "Marlene", result.getData().get(0).getName());
}
Aggregations