use of org.activityinfo.shared.command.UpdateUserPermissions in project activityinfo by bedatadriven.
the class DbUserEditor method add.
private void add() {
final UserForm form = new UserForm(db);
final FormDialogImpl dlg = new FormDialogImpl(form);
dlg.setHeading(I18N.CONSTANTS.newUser());
dlg.setWidth(400);
dlg.setHeight(300);
final String host = Window.Location.getHostName();
dlg.show(new FormDialogCallback() {
@Override
public void onValidated() {
dispatcher.execute(new UpdateUserPermissions(db, form.getUser(), host), dlg, new AsyncCallback<VoidResult>() {
@Override
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(VoidResult result) {
loader.load();
dlg.hide();
}
});
}
});
}
use of org.activityinfo.shared.command.UpdateUserPermissions in project activityinfo by bedatadriven.
the class UpdateUserPermissionsHandlerTest method ownerCanAddUser.
@Test
public void ownerCanAddUser() throws Exception {
UserPermissionDTO user = new UserPermissionDTO();
user.setEmail("other@foobar");
user.setName("Foo Bar");
user.setPartner(NRC_DTO);
user.setAllowView(true);
UpdateUserPermissions cmd = new UpdateUserPermissions(1, user);
handler.execute(cmd, owner);
assertThat(mailer.sentMails.size(), equalTo(1));
}
use of org.activityinfo.shared.command.UpdateUserPermissions 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.UpdateUserPermissions in project activityinfo by bedatadriven.
the class UpdateUserPermissionsHandlerTest method testVerifyAuthorityForViewPermissions.
/**
* Asserts that someone with ManageUsersPermission will be permitted to
* grant some one edit rights.
*/
@Test
public void testVerifyAuthorityForViewPermissions() throws IllegalAccessCommandException {
UserPermission executingUserPermissions = new UserPermission();
executingUserPermissions.setPartner(NRC);
executingUserPermissions.setAllowManageUsers(true);
UserPermissionDTO dto = new UserPermissionDTO();
dto.setPartner(NRC_DTO);
dto.setAllowView(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 testFailingVerifyAuthorityForView.
@Test(expected = IllegalAccessCommandException.class)
public void testFailingVerifyAuthorityForView() throws IllegalAccessCommandException {
UserPermission executingUserPermissions = new UserPermission();
executingUserPermissions.setPartner(IRC);
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);
}
Aggregations