use of org.activityinfo.legacy.shared.model.UserPermissionDTO in project activityinfo by bedatadriven.
the class DbUserExport method createDataRows.
private void createDataRows(Sheet sheet) {
((HSSFSheet) sheet).createDrawingPatriarch();
int rowIndex = 2;
for (UserPermissionDTO user : users) {
Row row = sheet.createRow(rowIndex++);
int column = 0;
createCell(row, column++, user.getName());
createCell(row, column++, user.getEmail());
createCell(row, column++, String.valueOf(user.getPartner()));
createCell(row, column++, String.valueOf(user.getAllowView()));
createCell(row, column++, String.valueOf(user.getAllowViewAll()));
createCell(row, column++, String.valueOf(user.getAllowDesign()));
createCell(row, column++, String.valueOf(user.getAllowEdit()));
createCell(row, column++, String.valueOf(user.getAllowEditAll()));
createCell(row, column++, String.valueOf(user.getAllowManageUsers()));
createCell(row, column++, String.valueOf(user.getAllowManageAllUsers()));
}
}
use of org.activityinfo.legacy.shared.model.UserPermissionDTO in project activityinfo by bedatadriven.
the class UpdateUserPermissionsHandlerTest method testVerifyAuthorityForEditPermissions.
/**
* Asserts that someone with ManageUsersPermission will be permitted to
* grant some one edit rights.
*/
@Test
public void testVerifyAuthorityForEditPermissions() throws IllegalAccessCommandException {
UserPermission executingUserPermissions = new UserPermission();
executingUserPermissions.setPartner(NRC);
executingUserPermissions.setAllowManageUsers(true);
UserPermissionDTO dto = new UserPermissionDTO();
dto.setPartner(NRC_DTO);
dto.setAllowView(true);
dto.setAllowEdit(true);
UpdateUserPermissions cmd = new UpdateUserPermissions(1, dto);
UpdateUserPermissionsHandler.verifyAuthority(cmd, executingUserPermissions);
}
use of org.activityinfo.legacy.shared.model.UserPermissionDTO in project activityinfo by bedatadriven.
the class UpdateUserPermissionsHandlerTest method testAuthorizedCreate.
/**
* Verifies that a user with the manageUsers permission can add another user to the UserDatabase
*/
@Test
@OnDataSet("/dbunit/schema1.db.xml")
public void testAuthorizedCreate() throws CommandException {
setUser(2);
UserPermissionDTO user = new UserPermissionDTO();
user.setEmail("ralph@lauren.com");
user.setName("Ralph");
user.setPartner(new PartnerDTO(1, "NRC"));
user.setAllowView(true);
user.setAllowEdit(true);
UpdateUserPermissions cmd = new UpdateUserPermissions(1, user);
execute(cmd);
UserResult result = execute(new GetUsers(1));
assertThat(result.getTotalLength(), equalTo(1));
UserPermissionDTO ralph = result.getData().get(0);
assertThat(ralph.getEmail(), equalTo("ralph@lauren.com"));
assertThat(ralph.getAllowEdit(), equalTo(true));
assertThat(ralph.hasFolderLimitation(), equalTo(false));
}
use of org.activityinfo.legacy.shared.model.UserPermissionDTO in project activityinfo by bedatadriven.
the class UpdateUserPermissionsHandlerTest method testFolderLevelUpdate.
@Test
@OnDataSet("/dbunit/schema3.db.xml")
public void testFolderLevelUpdate() {
setUser(1);
UserPermissionDTO newUser = new UserPermissionDTO();
newUser.setName("Bavon");
newUser.setEmail("bavon@nrcdrc.org");
newUser.setPartner(new PartnerDTO(1, "NRC"));
newUser.setAllowView(true);
newUser.setAllowViewAll(false);
newUser.setAllowEdit(true);
newUser.setAllowEdit(false);
newUser.setAllowDesign(true);
FolderDTO health = new FolderDTO();
health.setId(3);
newUser.setFolders(Arrays.asList(health));
newUser.setFolderLimitation(true);
execute(new UpdateUserPermissions(1, newUser));
UserResult users = execute(new GetUsers(1));
UserPermissionDTO bavon = users.getData().get(0);
assertThat(bavon.hasFolderLimitation(), equalTo(true));
}
use of org.activityinfo.legacy.shared.model.UserPermissionDTO 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
assertThat(result.getTotalLength(), equalTo(1));
UserPermissionDTO marlene = result.getData().get(0);
assertThat(marlene.getName(), equalTo("Marlene"));
assertThat(marlene.hasFolderLimitation(), equalTo(false));
}
Aggregations