use of org.activityinfo.shared.command.UpdateUserPermissions in project activityinfo by bedatadriven.
the class UpdateUserPermissionsHandlerTest method testVerifyAuthorityForViewByOtherPartner.
@Test
public void testVerifyAuthorityForViewByOtherPartner() throws IllegalAccessCommandException {
UserPermission executingUserPermissions = new UserPermission();
executingUserPermissions.setPartner(IRC);
executingUserPermissions.setAllowManageUsers(true);
executingUserPermissions.setAllowManageAllUsers(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.shared.command.UpdateUserPermissions in project activityinfo by bedatadriven.
the class DbUserEditor method delete.
private void delete() {
final UserPermissionDTO model = grid.getSelectionModel().getSelectedItem();
model.setAllowView(false);
model.setAllowViewAll(false);
model.setAllowEdit(false);
model.setAllowEditAll(false);
model.setAllowDesign(false);
model.setAllowManageAllUsers(false);
model.setAllowManageUsers(false);
dispatcher.execute(new UpdateUserPermissions(db.getId(), model), new MaskingAsyncMonitor(this, I18N.CONSTANTS.deleting()), new AsyncCallback<VoidResult>() {
@Override
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(VoidResult result) {
store.remove(model);
}
});
}
use of org.activityinfo.shared.command.UpdateUserPermissions in project activityinfo by bedatadriven.
the class DbUserEditor method save.
private void save() {
BatchCommand batch = new BatchCommand();
for (Record record : store.getModifiedRecords()) {
batch.add(new UpdateUserPermissions(db.getId(), (UserPermissionDTO) record.getModel()));
}
dispatcher.execute(batch, new MaskingAsyncMonitor(this, I18N.CONSTANTS.saving()), new AsyncCallback<BatchResult>() {
@Override
public void onFailure(Throwable caught) {
// handled by monitor
}
@Override
public void onSuccess(BatchResult result) {
store.commitChanges();
}
});
}
use of org.activityinfo.shared.command.UpdateUserPermissions 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.shared.command.UpdateUserPermissions 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
*
* @throws CommandException
*/
@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));
Assert.assertEquals(1, result.getTotalLength());
Assert.assertEquals("ralph@lauren.com", result.getData().get(0).getEmail());
Assert.assertTrue("edit permissions", result.getData().get(0).getAllowEdit());
}
Aggregations