Search in sources :

Example 6 with UserResult

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

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

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

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

UserResult (org.activityinfo.legacy.shared.command.result.UserResult)9 GetUsers (org.activityinfo.legacy.shared.command.GetUsers)8 Test (org.junit.Test)7 UserPermissionDTO (org.activityinfo.legacy.shared.model.UserPermissionDTO)5 PartnerDTO (org.activityinfo.legacy.shared.model.PartnerDTO)4 OnDataSet (org.activityinfo.server.database.OnDataSet)4 UpdateUserPermissions (org.activityinfo.legacy.shared.command.UpdateUserPermissions)3 OutputStream (java.io.OutputStream)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)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 ResourceId (org.activityinfo.model.resource.ResourceId)1 CommandTestCase2 (org.activityinfo.server.command.CommandTestCase2)1