TSK-1441: Enable Admin to complete tasks already claimed by other users

This commit is contained in:
Joerg Heffner 2020-11-05 09:11:12 +01:00 committed by gitgoodjhe
parent 5ddb81a618
commit 81b89e1c08
2 changed files with 17 additions and 4 deletions

View File

@ -1244,10 +1244,11 @@ public class TaskServiceImpl implements TaskService {
throw new InvalidStateException(
String.format("Task with Id %s has to be claimed before.", task.getId()));
} else if (!taskanaEngine
.getEngine()
.getCurrentUserContext()
.getAccessIds()
.contains(task.getOwner())) {
.getEngine()
.getCurrentUserContext()
.getAccessIds()
.contains(task.getOwner())
&& !taskanaEngine.getEngine().isUserInRole(TaskanaRole.ADMIN)) {
throw new InvalidOwnerException(
String.format(
"Owner of task %s is %s, but current user is %s ",

View File

@ -45,6 +45,18 @@ class CompleteTaskAccTest extends AbstractAccTest {
assertThat(completedTask.getModified()).isNotEqualTo(completedTask.getCreated());
}
@WithAccessId(user = "admin")
@Test
void should_completeClaimedTaskByAnotherUser_When_UserIsAdmin() throws Exception {
assertThat(TASK_SERVICE.getTask("TKI:000000000000000000000000000000000029").getState())
.isEqualTo(TaskState.CLAIMED);
Task completedTask = TASK_SERVICE.completeTask("TKI:000000000000000000000000000000000029");
assertThat(completedTask).isNotNull();
assertThat(completedTask.getCompleted()).isNotNull();
assertThat(completedTask.getState()).isEqualTo(TaskState.COMPLETED);
assertThat(completedTask.getModified()).isNotEqualTo(completedTask.getCreated());
}
@WithAccessId(user = "admin")
@WithAccessId(user = "taskadmin")
@TestTemplate