Search in sources :

Example 1 with ActiveAccessRequestWrapper

use of org.finra.gatekeeper.controllers.wrappers.ActiveAccessRequestWrapper in project Gatekeeper by FINRAOS.

the class AccessRequestService method getActiveRequests.

public List<ActiveAccessRequestWrapper> getActiveRequests() {
    List<Task> tasks = taskService.createTaskQuery().active().list();
    List<ActiveAccessRequestWrapper> response = new ArrayList<>();
    tasks.forEach(task -> {
        AccessRequest theRequest = (AccessRequest) runtimeService.getVariable(task.getExecutionId(), "accessRequest");
        response.add(new ActiveAccessRequestWrapper(theRequest).setCreated(task.getCreateTime()).setTaskId(task.getId()).setInstanceCount(theRequest.getAwsRdsInstances().size()).setUserCount(theRequest.getUsers().size()));
    });
    return (List<ActiveAccessRequestWrapper>) filterResults(response);
}
Also used : Task(org.activiti.engine.task.Task) ActiveAccessRequestWrapper(org.finra.gatekeeper.controllers.wrappers.ActiveAccessRequestWrapper)

Example 2 with ActiveAccessRequestWrapper

use of org.finra.gatekeeper.controllers.wrappers.ActiveAccessRequestWrapper in project Gatekeeper by FINRAOS.

the class AccessRequestServiceTest method testGetActiveRequests.

/**
 * Test for checking that, when the user is DEV, they should be able to see
 * only the requests that are active and were requested by themselves
 */
@Test
public void testGetActiveRequests() {
    when(gatekeeperRoleService.getUserProfile().getName()).thenReturn("owner");
    when(gatekeeperRoleService.getRole()).thenReturn(GatekeeperRdsRole.DEV);
    List<ActiveAccessRequestWrapper> activeRequests = accessRequestService.getActiveRequests();
    Assert.assertEquals(activeRequests.size(), 1);
    ActiveAccessRequestWrapper ownerRequest = activeRequests.get(0);
    Assert.assertEquals(ownerRequest.getUserCount(), new Integer(1));
    Assert.assertEquals(ownerRequest.getInstanceCount(), new Integer(1));
    Assert.assertEquals(ownerRequest.getCreated().toString(), new Date(4500000).toString());
    Assert.assertEquals(ownerRequest.getTaskId(), "taskOne");
    when(gatekeeperRoleService.getUserProfile().getName()).thenReturn("non-owner");
    when(gatekeeperRoleService.getRole()).thenReturn(GatekeeperRdsRole.DEV);
    activeRequests = accessRequestService.getActiveRequests();
    Assert.assertEquals(activeRequests.size(), 1);
    ActiveAccessRequestWrapper nonOwnerRequest = activeRequests.get(0);
    Assert.assertEquals(nonOwnerRequest.getUserCount(), new Integer(0));
    Assert.assertEquals(nonOwnerRequest.getInstanceCount(), new Integer(1));
    Assert.assertEquals(nonOwnerRequest.getCreated().toString(), testDate.toString());
    Assert.assertEquals(nonOwnerRequest.getTaskId(), "taskTwo");
}
Also used : ActiveAccessRequestWrapper(org.finra.gatekeeper.controllers.wrappers.ActiveAccessRequestWrapper) Test(org.junit.Test)

Example 3 with ActiveAccessRequestWrapper

use of org.finra.gatekeeper.controllers.wrappers.ActiveAccessRequestWrapper in project Gatekeeper by FINRAOS.

the class AccessRequestServiceTest method testGetActiveRequestsAdmin.

/**
 * Test for checking that, when the user is APPROVER, they should be able to see
 * any active request. Even ones that they do not own.
 */
@Test
public void testGetActiveRequestsAdmin() {
    when(gatekeeperRoleService.getRole()).thenReturn(GatekeeperRdsRole.APPROVER);
    List<ActiveAccessRequestWrapper> activeRequests = accessRequestService.getActiveRequests();
    Assert.assertTrue(activeRequests.size() == 2);
    ActiveAccessRequestWrapper ownerRequest = activeRequests.get(0);
    Assert.assertEquals(ownerRequest.getUserCount(), new Integer(1));
    Assert.assertEquals(ownerRequest.getInstanceCount(), new Integer(1));
    Assert.assertEquals(ownerRequest.getCreated().toString(), new Date(4500000).toString());
    Assert.assertEquals(ownerRequest.getTaskId(), "taskOne");
    ActiveAccessRequestWrapper nonOwnerRequest = activeRequests.get(1);
    Assert.assertEquals(nonOwnerRequest.getUserCount(), new Integer(0));
    Assert.assertEquals(nonOwnerRequest.getInstanceCount(), new Integer(1));
    Assert.assertEquals(nonOwnerRequest.getCreated().toString(), testDate.toString());
    Assert.assertEquals(nonOwnerRequest.getTaskId(), "taskTwo");
}
Also used : ActiveAccessRequestWrapper(org.finra.gatekeeper.controllers.wrappers.ActiveAccessRequestWrapper) Test(org.junit.Test)

Example 4 with ActiveAccessRequestWrapper

use of org.finra.gatekeeper.controllers.wrappers.ActiveAccessRequestWrapper in project Gatekeeper by FINRAOS.

the class AccessRequestServiceTests method testGetActiveRequests.

/**
 * Test for checking that, when the user is DEV, they should be able to see
 * only the requests that are active and were requested by themselves
 */
@Test
public void testGetActiveRequests() {
    when(gatekeeperLdapService.getRole()).thenReturn(GatekeeperRole.DEV);
    when(gatekeeperLdapService.getUserProfile().getName()).thenReturn("owner");
    List<ActiveAccessRequestWrapper> activeRequests = accessRequestService.getActiveRequests();
    Assert.assertEquals(activeRequests.size(), 1);
    ActiveAccessRequestWrapper ownerRequest = activeRequests.get(0);
    Assert.assertEquals(ownerRequest.getUserCount(), new Integer(1));
    Assert.assertEquals(ownerRequest.getInstanceCount(), new Integer(1));
    Assert.assertEquals(ownerRequest.getCreated().toString(), new Date(4500000).toString());
    Assert.assertEquals(ownerRequest.getTaskId(), "taskOne");
    when(gatekeeperLdapService.getUserProfile().getName()).thenReturn("non-owner");
    activeRequests = accessRequestService.getActiveRequests();
    Assert.assertEquals(activeRequests.size(), 1);
    ActiveAccessRequestWrapper nonOwnerRequest = activeRequests.get(0);
    Assert.assertEquals(nonOwnerRequest.getUserCount(), new Integer(0));
    Assert.assertEquals(nonOwnerRequest.getInstanceCount(), new Integer(1));
    Assert.assertEquals(nonOwnerRequest.getCreated().toString(), testDate.toString());
    Assert.assertEquals(nonOwnerRequest.getTaskId(), "taskTwo");
}
Also used : ActiveAccessRequestWrapper(org.finra.gatekeeper.controllers.wrappers.ActiveAccessRequestWrapper) Test(org.junit.Test)

Example 5 with ActiveAccessRequestWrapper

use of org.finra.gatekeeper.controllers.wrappers.ActiveAccessRequestWrapper in project Gatekeeper by FINRAOS.

the class AccessRequestServiceTests method testGetActiveRequestsAdmin.

/**
 * Test for checking that, when the user is APPROVER, they should be able to see
 * any active request. Even ones that they do not own.
 */
@Test
public void testGetActiveRequestsAdmin() {
    when(gatekeeperLdapService.getRole()).thenReturn(GatekeeperRole.APPROVER);
    List<ActiveAccessRequestWrapper> activeRequests = accessRequestService.getActiveRequests();
    Assert.assertTrue(activeRequests.size() == 2);
    ActiveAccessRequestWrapper ownerRequest = activeRequests.get(0);
    Assert.assertEquals(ownerRequest.getUserCount(), new Integer(1));
    Assert.assertEquals(ownerRequest.getInstanceCount(), new Integer(1));
    Assert.assertEquals(ownerRequest.getCreated().toString(), new Date(4500000).toString());
    Assert.assertEquals(ownerRequest.getTaskId(), "taskOne");
    ActiveAccessRequestWrapper nonOwnerRequest = activeRequests.get(1);
    Assert.assertEquals(nonOwnerRequest.getUserCount(), new Integer(0));
    Assert.assertEquals(nonOwnerRequest.getInstanceCount(), new Integer(1));
    Assert.assertEquals(nonOwnerRequest.getCreated().toString(), testDate.toString());
    Assert.assertEquals(nonOwnerRequest.getTaskId(), "taskTwo");
}
Also used : ActiveAccessRequestWrapper(org.finra.gatekeeper.controllers.wrappers.ActiveAccessRequestWrapper) Test(org.junit.Test)

Aggregations

ActiveAccessRequestWrapper (org.finra.gatekeeper.controllers.wrappers.ActiveAccessRequestWrapper)5 Test (org.junit.Test)4 Task (org.activiti.engine.task.Task)1