Search in sources :

Example 11 with UserPermissionDTO

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()));
    }
}
Also used : HSSFSheet(org.apache.poi.hssf.usermodel.HSSFSheet) Row(org.apache.poi.ss.usermodel.Row) UserPermissionDTO(org.activityinfo.legacy.shared.model.UserPermissionDTO)

Example 12 with UserPermissionDTO

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);
}
Also used : UpdateUserPermissions(org.activityinfo.legacy.shared.command.UpdateUserPermissions) UserPermissionDTO(org.activityinfo.legacy.shared.model.UserPermissionDTO) Test(org.junit.Test)

Example 13 with UserPermissionDTO

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));
}
Also used : PartnerDTO(org.activityinfo.legacy.shared.model.PartnerDTO) UpdateUserPermissions(org.activityinfo.legacy.shared.command.UpdateUserPermissions) UserResult(org.activityinfo.legacy.shared.command.result.UserResult) GetUsers(org.activityinfo.legacy.shared.command.GetUsers) UserPermissionDTO(org.activityinfo.legacy.shared.model.UserPermissionDTO) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 14 with UserPermissionDTO

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));
}
Also used : FolderDTO(org.activityinfo.legacy.shared.model.FolderDTO) PartnerDTO(org.activityinfo.legacy.shared.model.PartnerDTO) UpdateUserPermissions(org.activityinfo.legacy.shared.command.UpdateUserPermissions) UserResult(org.activityinfo.legacy.shared.command.result.UserResult) GetUsers(org.activityinfo.legacy.shared.command.GetUsers) UserPermissionDTO(org.activityinfo.legacy.shared.model.UserPermissionDTO) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 15 with UserPermissionDTO

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));
}
Also used : UserResult(org.activityinfo.legacy.shared.command.result.UserResult) GetUsers(org.activityinfo.legacy.shared.command.GetUsers) UserPermissionDTO(org.activityinfo.legacy.shared.model.UserPermissionDTO) Test(org.junit.Test)

Aggregations

UserPermissionDTO (org.activityinfo.legacy.shared.model.UserPermissionDTO)15 UpdateUserPermissions (org.activityinfo.legacy.shared.command.UpdateUserPermissions)10 Test (org.junit.Test)9 UserResult (org.activityinfo.legacy.shared.command.result.UserResult)5 GetUsers (org.activityinfo.legacy.shared.command.GetUsers)4 PartnerDTO (org.activityinfo.legacy.shared.model.PartnerDTO)4 OnDataSet (org.activityinfo.server.database.OnDataSet)3 Database (org.activityinfo.server.database.hibernate.entity.Database)2 UserPermission (org.activityinfo.server.database.hibernate.entity.UserPermission)2 MaskingAsyncMonitor (org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor)2 Record (com.extjs.gxt.ui.client.store.Record)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 BatchCommand (org.activityinfo.legacy.shared.command.BatchCommand)1 BatchResult (org.activityinfo.legacy.shared.command.result.BatchResult)1 UserExistsException (org.activityinfo.legacy.shared.command.result.UserExistsException)1 VoidResult (org.activityinfo.legacy.shared.command.result.VoidResult)1 FolderDTO (org.activityinfo.legacy.shared.model.FolderDTO)1 ResourceId (org.activityinfo.model.resource.ResourceId)1 Folder (org.activityinfo.server.database.hibernate.entity.Folder)1