Search in sources :

Example 6 with GetUsers

use of org.activityinfo.legacy.shared.command.GetUsers 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 7 with GetUsers

use of org.activityinfo.legacy.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);
    assertThat(result.getData(), hasSize(3));
}
Also used : UserResult(org.activityinfo.legacy.shared.command.result.UserResult) GetUsers(org.activityinfo.legacy.shared.command.GetUsers) Test(org.junit.Test)

Example 8 with GetUsers

use of org.activityinfo.legacy.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
    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

GetUsers (org.activityinfo.legacy.shared.command.GetUsers)8 UserResult (org.activityinfo.legacy.shared.command.result.UserResult)8 Test (org.junit.Test)7 UserPermissionDTO (org.activityinfo.legacy.shared.model.UserPermissionDTO)4 OnDataSet (org.activityinfo.server.database.OnDataSet)4 UpdateUserPermissions (org.activityinfo.legacy.shared.command.UpdateUserPermissions)3 PartnerDTO (org.activityinfo.legacy.shared.model.PartnerDTO)3 OutputStream (java.io.OutputStream)1 Date (java.util.Date)1 Optional (java.util.Optional)1 InjectionSupport (org.activityinfo.fixtures.InjectionSupport)1 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)1 GetSites (org.activityinfo.legacy.shared.command.GetSites)1 UpdatePartner (org.activityinfo.legacy.shared.command.UpdatePartner)1 org.activityinfo.legacy.shared.model (org.activityinfo.legacy.shared.model)1 FolderDTO (org.activityinfo.legacy.shared.model.FolderDTO)1 CommandTestCase2 (org.activityinfo.server.command.CommandTestCase2)1 Timed (org.activityinfo.server.util.monitoring.Timed)1 Matchers (org.hamcrest.Matchers)1 IsEqual.equalTo (org.hamcrest.core.IsEqual.equalTo)1