use of pro.taskana.WorkbasketPermission in project taskana by Taskana.
the class WorkbasketServiceImplTest method testGetWorkbasketById.
@Test
public void testGetWorkbasketById() throws NotAuthorizedException, WorkbasketNotFoundException {
String wbId = "ID-1";
Workbasket wb = createTestWorkbasket(wbId, "key-1");
WorkbasketPermission authorization = WorkbasketPermission.READ;
doReturn(wb).when(workbasketMapperMock).findById(wbId);
doNothing().when(cutSpy).checkAuthorization(wb.getId(), authorization);
Workbasket actualWb = cutSpy.getWorkbasket(wbId);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(workbasketMapperMock, times(1)).findById(wbId);
verify(cutSpy, times(1)).checkAuthorization(wb.getId(), authorization);
verify(taskanaEngineImplMock, times(1)).returnConnection();
verify(taskanaEngineImplMock, times(1)).isUserInRole(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, distributionTargetMapperMock, taskanaEngineImplMock, taskanaEngineConfigurationMock);
assertThat(actualWb, equalTo(wb));
}
use of pro.taskana.WorkbasketPermission in project taskana by Taskana.
the class WorkbasketServiceImplTest method testGetWorkbasketById_NonAuthorizedUser.
@Test(expected = NotAuthorizedException.class)
public void testGetWorkbasketById_NonAuthorizedUser() throws WorkbasketNotFoundException, NotAuthorizedException {
String wbId = "ID-1";
Workbasket wb = createTestWorkbasket(wbId, "Key-1");
WorkbasketPermission authorization = WorkbasketPermission.READ;
doReturn(wb).when(workbasketMapperMock).findById(wbId);
doThrow(NotAuthorizedException.class).when(cutSpy).checkAuthorization(wb.getId(), authorization);
try {
cutSpy.getWorkbasket(wbId);
} catch (NotAuthorizedException ex) {
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(workbasketMapperMock, times(1)).findById(wbId);
verify(cutSpy, times(1)).checkAuthorization(wb.getId(), authorization);
verify(taskanaEngineImplMock, times(1)).returnConnection();
verify(taskanaEngineImplMock, times(1)).isUserInRole(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, distributionTargetMapperMock, taskanaEngineImplMock, taskanaEngineConfigurationMock);
throw ex;
}
}
use of pro.taskana.WorkbasketPermission in project taskana by Taskana.
the class WorkbasketServiceImplTest method testGetWorkbasketByKey_NonAuthorizedUser.
@Test(expected = NotAuthorizedException.class)
public void testGetWorkbasketByKey_NonAuthorizedUser() throws WorkbasketNotFoundException, NotAuthorizedException {
String wbKey = "Key-1";
Workbasket wb = createTestWorkbasket("ID", wbKey);
WorkbasketPermission authorization = WorkbasketPermission.READ;
doReturn(wb).when(workbasketMapperMock).findByKeyAndDomain(wbKey, "domain");
doThrow(NotAuthorizedException.class).when(cutSpy).checkAuthorization(wbKey, "domain", authorization);
try {
cutSpy.getWorkbasket(wbKey, "domain");
} catch (NotAuthorizedException ex) {
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(workbasketMapperMock, times(1)).findByKeyAndDomain(wbKey, "domain");
verify(cutSpy, times(1)).checkAuthorization(wbKey, "domain", authorization);
verify(taskanaEngineImplMock, times(1)).returnConnection();
verify(taskanaEngineImplMock, times(1)).isUserInRole(any());
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, distributionTargetMapperMock, taskanaEngineImplMock, taskanaEngineConfigurationMock);
throw ex;
}
}
use of pro.taskana.WorkbasketPermission in project taskana by Taskana.
the class GetWorkbasketAccTest method testGetWorkbasketPermissions.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testGetWorkbasketPermissions() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketPermission> permissions = workbasketService.getPermissionsForWorkbasket("WBI:100000000000000000000000000000000007");
Assert.assertEquals(4, permissions.size());
Assert.assertTrue(permissions.contains(WorkbasketPermission.READ));
Assert.assertTrue(permissions.contains(WorkbasketPermission.OPEN));
Assert.assertTrue(permissions.contains(WorkbasketPermission.TRANSFER));
Assert.assertTrue(permissions.contains(WorkbasketPermission.APPEND));
}
use of pro.taskana.WorkbasketPermission in project taskana by Taskana.
the class WorkbasketServiceImpl method getPermissionsForWorkbasket.
@Override
public List<WorkbasketPermission> getPermissionsForWorkbasket(String workbasketId) {
List<WorkbasketPermission> permissions = new ArrayList<>();
WorkbasketAccessItem wbAcc = workbasketAccessMapper.findByWorkbasketAndAccessId(workbasketId, CurrentUserContext.getAccessIds());
this.addWorkbasketAccessItemValuesToPermissionSet(wbAcc, permissions);
return permissions;
}
Aggregations