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);
}
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");
}
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");
}
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");
}
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");
}
Aggregations