Usage of the new TestTemplate-feature

-for running tests multiple times with different AccessIds
This commit is contained in:
Jörg Heffner 2020-04-28 10:34:06 +02:00
parent eb73c0670f
commit baf794518c
22 changed files with 323 additions and 254 deletions

View File

@ -6,6 +6,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import acceptance.AbstractAccTest;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.classification.api.ClassificationService;
@ -269,8 +270,9 @@ class CreateClassificationAccTest extends AbstractAccTest {
}
@WithAccessId(user = "taskadmin")
@Test
void should_ThrowException_When_UserIsTaskAdminAndNotAuthorizedToCreateClassification() {
@WithAccessId(user = "user_1_1")
@TestTemplate
void should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdmin() {
ClassificationImpl classification =
(ClassificationImpl) classificationService.newClassification("newKey718", "", "TASK");

View File

@ -6,6 +6,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import acceptance.AbstractAccTest;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.classification.api.ClassificationService;
@ -16,7 +17,9 @@ import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.internal.security.JaasExtension;
import pro.taskana.common.internal.security.WithAccessId;
/** Acceptance test for all "delete classification" scenarios. */
/**
* Acceptance test for all "delete classification" scenarios.
*/
@ExtendWith(JaasExtension.class)
class DeleteClassificationAccTest extends AbstractAccTest {
@ -48,17 +51,16 @@ class DeleteClassificationAccTest extends AbstractAccTest {
}
@WithAccessId(user = "taskadmin")
@Test
void
should_ThrowException_When_UserIsTaskAdminAndNotAuthorizedToDelClassificationByKeyDomain() {
ThrowingCallable call = () -> classificationService.deleteClassification("L140101", "DOMAIN_A");
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
}
@WithAccessId(user = "user_1_1")
@TestTemplate
void should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdmin() {
@WithAccessId(user = "taskadmin")
@Test
void should_ThrowException_When_UserIsTaskAdminAndNotAuthorizedToDeleteClassificationById() {
ThrowingCallable call =
() -> classificationService.deleteClassification("L140101", "DOMAIN_A");
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
call =
() ->
classificationService.deleteClassification("CLI:000000000000000000000000000000000009");
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);

View File

@ -11,6 +11,7 @@ import java.util.Arrays;
import java.util.List;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.classification.api.ClassificationService;
@ -111,8 +112,9 @@ public class UpdateClassificationAccTest extends AbstractAccTest {
}
@WithAccessId(user = "taskadmin")
@Test
public void should_ThrowException_When_UserIsTaskAdminAndNotAuthorizedToUpdateClassification()
@WithAccessId(user = "user_1_1")
@TestTemplate
public void should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdmin()
throws ClassificationNotFoundException {
Classification classification = classificationService.getClassification("T2100", "DOMAIN_A");

View File

@ -74,9 +74,9 @@ class TaskanaRoleConfigAccTest extends TaskanaEngineImpl {
Set<String> businessAdmins = getConfiguration().getRoleMap().get(TaskanaRole.BUSINESS_ADMIN);
assertThat(businessAdmins).containsOnly("ebe", "konstantin");
Set<String> taskAdmins = getConfiguration().getRoleMap().get(TaskanaRole.TASK_ADMIN);
assertThat(taskAdmins).contains("taskadmin", "peter");
Set<String> taskAdmins = getConfiguration().getRoleMap().get(TaskanaRole.TASK_ADMIN);
assertThat(taskAdmins).contains("taskadmin", "peter");
} finally {
deleteFile(propertiesFileName);
}
@ -102,9 +102,9 @@ class TaskanaRoleConfigAccTest extends TaskanaEngineImpl {
Set<String> businessAdmins = getConfiguration().getRoleMap().get(TaskanaRole.BUSINESS_ADMIN);
assertThat(businessAdmins).containsOnly("name=ebe, ou = bpm", "konstantin");
Set<String> taskAdmins = getConfiguration().getRoleMap().get(TaskanaRole.TASK_ADMIN);
assertThat(taskAdmins).contains("taskadmin", "peter");
Set<String> taskAdmins = getConfiguration().getRoleMap().get(TaskanaRole.TASK_ADMIN);
assertThat(taskAdmins).contains("taskadmin", "peter");
} finally {
deleteFile(propertiesFileName);
}

View File

@ -4,10 +4,12 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import acceptance.AbstractAccTest;
import java.sql.SQLException;
import java.util.List;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
@ -20,9 +22,12 @@ import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.Task;
import pro.taskana.task.api.models.TaskSummary;
/** Acceptance tests for all "cancel task" scenarios. */
/**
* Acceptance tests for all "cancel task" scenarios.
*/
@ExtendWith(JaasExtension.class)
class CancelTaskAccTest extends AbstractAccTest {
private TaskService taskService;
CancelTaskAccTest() {
@ -56,11 +61,13 @@ class CancelTaskAccTest extends AbstractAccTest {
assertThat(numTasks).isEqualTo(6);
}
@WithAccessId(user = "admin")
@WithAccessId(user = "taskadmin")
@Test
void should_CancelTask_When_NoExplicitPermissionsButUserIsInTaskAdminRole()
throws NotAuthorizedException, TaskNotFoundException, InvalidStateException {
@TestTemplate
void should_CancelTask_When_NoExplicitPermissionsButUserIsInAdministrativeRole()
throws NotAuthorizedException, TaskNotFoundException, InvalidStateException, SQLException {
resetDb(false);
Task tasktoCancel = taskService.getTask("TKI:000000000000000000000000000000000001");
assertThat(tasktoCancel.getState()).isEqualTo(TaskState.CLAIMED);

View File

@ -4,9 +4,11 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import acceptance.AbstractAccTest;
import java.sql.SQLException;
import java.time.Instant;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.classification.api.exceptions.ClassificationNotFoundException;
@ -25,7 +27,9 @@ import pro.taskana.task.api.models.Task;
import pro.taskana.task.internal.models.TaskImpl;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
/** Acceptance tests for all claim and complete scenarios. */
/**
* Acceptance tests for all claim and complete scenarios.
*/
@ExtendWith(JaasExtension.class)
class CompleteTaskAccTest extends AbstractAccTest {
@ -37,7 +41,7 @@ class CompleteTaskAccTest extends AbstractAccTest {
@Test
void testCompleteTask()
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
NotAuthorizedException {
NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService();
assertThat(taskService.getTask("TKI:000000000000000000000000000000000001").getState())
@ -49,11 +53,14 @@ class CompleteTaskAccTest extends AbstractAccTest {
assertThat(completedTask.getModified()).isNotEqualTo(completedTask.getCreated());
}
@WithAccessId(user = "admin")
@WithAccessId(user = "taskadmin")
@Test
void should_ForceCompleteTask_When_NoExplicitPermissionsButUserIsInTaskAdminRole()
@TestTemplate
void should_ForceCompleteTask_When_NoExplicitPermissionsButUserIsInAdministrativeRole()
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
NotAuthorizedException {
NotAuthorizedException, SQLException {
resetDb(false);
TaskService taskService = taskanaEngine.getTaskService();
assertThat(taskService.getTask("TKI:000000000000000000000000000000000000").getState())
@ -69,7 +76,7 @@ class CompleteTaskAccTest extends AbstractAccTest {
@Test
void testCompleteTaskTwice()
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
NotAuthorizedException {
NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService();
Task completedTask = taskService.completeTask("TKI:000000000000000000000000000000000002");
Task completedTask2 = taskService.completeTask("TKI:000000000000000000000000000000000002");
@ -80,8 +87,8 @@ class CompleteTaskAccTest extends AbstractAccTest {
@Test
void testForceCompleteAlreadyClaimed()
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidOwnerException, InvalidStateException {
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidOwnerException, InvalidStateException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
@ -106,8 +113,8 @@ class CompleteTaskAccTest extends AbstractAccTest {
@Test
void testForceCompleteNotClaimed()
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidOwnerException, InvalidStateException {
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidOwnerException, InvalidStateException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
@ -161,8 +168,8 @@ class CompleteTaskAccTest extends AbstractAccTest {
@Test
void testClaimTaskWithDefaultFlag()
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
@ -191,8 +198,8 @@ class CompleteTaskAccTest extends AbstractAccTest {
@Test
void testForceClaimTaskFromOtherUser()
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
@ -269,8 +276,8 @@ class CompleteTaskAccTest extends AbstractAccTest {
@Test
void testCancelClaimDefaultFlag()
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
@ -292,7 +299,7 @@ class CompleteTaskAccTest extends AbstractAccTest {
@Test
void testForceCancelClaimSuccessfull()
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
NotAuthorizedException, InterruptedException {
NotAuthorizedException, InterruptedException {
TaskService taskService = taskanaEngine.getTaskService();
Task taskBefore = taskService.getTask("TKI:000000000000000000000000000000000043");

View File

@ -17,6 +17,7 @@ import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.assertj.core.data.TemporalUnitWithinOffset;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.classification.api.ClassificationService;
@ -47,7 +48,9 @@ import pro.taskana.workbasket.api.models.Workbasket;
// import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
/** Acceptance test for all "create task" scenarios. */
/**
* Acceptance test for all "create task" scenarios.
*/
@ExtendWith(JaasExtension.class)
class CreateTaskAccTest extends AbstractAccTest {
@ -79,7 +82,7 @@ class CreateTaskAccTest extends AbstractAccTest {
@Test
void testCreateSimpleManualTask()
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException {
WorkbasketNotFoundException, TaskAlreadyExistException {
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
newTask.setClassificationKey("T2100");
@ -109,18 +112,21 @@ class CreateTaskAccTest extends AbstractAccTest {
assertThat(createdTask.isTransferred()).isFalse();
}
@WithAccessId(user = "admin")
@WithAccessId(user = "taskadmin")
@Test
void should_CreateTask_When_NoExplicitPermissionsButUserIsInTaskAdminRole()
@TestTemplate
void should_CreateTask_When_NoExplicitPermissionsButUserIsInAdministrativeRole()
throws TaskAlreadyExistException, InvalidArgumentException, WorkbasketNotFoundException,
NotAuthorizedException, ClassificationNotFoundException {
NotAuthorizedException, ClassificationNotFoundException {
String currentUser = CurrentUserContext.getUserid();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
newTask.setClassificationKey("T2100");
ObjectReference objectReference =
createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567");
newTask.setPrimaryObjRef(objectReference);
newTask.setOwner("taskadmin");
newTask.setOwner(currentUser);
Task createdTask = taskService.createTask(newTask);
assertThat(createdTask).isNotNull();
@ -131,7 +137,7 @@ class CreateTaskAccTest extends AbstractAccTest {
@Test
void testCreateTaskWithPlanned()
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException {
WorkbasketNotFoundException, TaskAlreadyExistException {
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
Instant instantPlanned = Instant.now().plus(2, ChronoUnit.HOURS);
@ -208,7 +214,7 @@ class CreateTaskAccTest extends AbstractAccTest {
@Test
void testIdempotencyOfTaskCreation()
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException {
WorkbasketNotFoundException, TaskAlreadyExistException {
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
newTask.setExternalId("MyExternalId");
@ -252,8 +258,8 @@ class CreateTaskAccTest extends AbstractAccTest {
@Test
void testCreateSimpleTaskWithCustomAttributes()
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, TaskNotFoundException,
NoSuchFieldException, IllegalAccessException {
WorkbasketNotFoundException, TaskAlreadyExistException, TaskNotFoundException,
NoSuchFieldException, IllegalAccessException {
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
newTask.setClassificationKey("T2100");
@ -319,8 +325,8 @@ class CreateTaskAccTest extends AbstractAccTest {
@Test
void testCreateExternalTaskWithAttachment()
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, TaskNotFoundException,
NoSuchFieldException, IllegalAccessException {
WorkbasketNotFoundException, TaskAlreadyExistException, TaskNotFoundException,
NoSuchFieldException, IllegalAccessException {
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
newTask.setClassificationKey("L12010");
@ -405,7 +411,7 @@ class CreateTaskAccTest extends AbstractAccTest {
@Test
void testCreateExternalTaskWithMultipleAttachments()
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, TaskNotFoundException {
WorkbasketNotFoundException, TaskAlreadyExistException, TaskNotFoundException {
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
newTask.setClassificationKey("L12010");
@ -457,7 +463,7 @@ class CreateTaskAccTest extends AbstractAccTest {
@Test
void testCalculationOfDueDateAtCreate()
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, TaskNotFoundException {
WorkbasketNotFoundException, TaskAlreadyExistException, TaskNotFoundException {
// SL P16D
Classification classification = classificationService.getClassification("L110105", "DOMAIN_A");
@ -490,7 +496,7 @@ class CreateTaskAccTest extends AbstractAccTest {
@Test
void testCalculationOfPlannedDateAtCreate()
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, TaskNotFoundException {
WorkbasketNotFoundException, TaskAlreadyExistException, TaskNotFoundException {
// SL P16D
Classification classification = classificationService.getClassification("L110105", "DOMAIN_A");
@ -525,7 +531,7 @@ class CreateTaskAccTest extends AbstractAccTest {
@Test
void testPrioDurationOfTaskFromAttachmentsAtCreate()
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, TaskNotFoundException {
WorkbasketNotFoundException, TaskAlreadyExistException, TaskNotFoundException {
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
newTask.setClassificationKey("L12010"); // prio 8, SL P7D
@ -670,7 +676,7 @@ class CreateTaskAccTest extends AbstractAccTest {
@Test
void testUseCustomNameIfSetForNewTask()
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException {
WorkbasketNotFoundException, TaskAlreadyExistException {
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
newTask.setClassificationKey("T2100");
@ -688,7 +694,7 @@ class CreateTaskAccTest extends AbstractAccTest {
@Test
void testUseClassificationMetadataFromCorrectDomainForNewTask()
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException {
WorkbasketNotFoundException, TaskAlreadyExistException {
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
newTask.setClassificationKey("T2100");
@ -769,7 +775,7 @@ class CreateTaskAccTest extends AbstractAccTest {
@Test
void testSetDomainFromWorkbasket()
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException {
WorkbasketNotFoundException, TaskAlreadyExistException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
@ -791,7 +797,7 @@ class CreateTaskAccTest extends AbstractAccTest {
@Test
void testCreatedTaskObjectEqualsReadTaskObject()
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, TaskNotFoundException {
WorkbasketNotFoundException, TaskAlreadyExistException, TaskNotFoundException {
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
newTask.setClassificationKey("T2100");
@ -825,7 +831,7 @@ class CreateTaskAccTest extends AbstractAccTest {
@Test
void testCreateSimpleTaskWithCallbackInfo()
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException {
TaskAlreadyExistException, InvalidArgumentException, TaskNotFoundException {
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
newTask.setClassificationKey("T2100");
@ -903,8 +909,8 @@ class CreateTaskAccTest extends AbstractAccTest {
@Test
void testCreateTaskWithWorkbasketMarkedForDeletion()
throws NotAuthorizedException, InvalidStateException, TaskNotFoundException,
TaskAlreadyExistException, InvalidArgumentException, WorkbasketNotFoundException,
ClassificationNotFoundException, WorkbasketInUseException {
TaskAlreadyExistException, InvalidArgumentException, WorkbasketNotFoundException,
ClassificationNotFoundException, WorkbasketInUseException {
String wbId = "WBI:100000000000000000000000000000000008";
Task taskToPreventWorkbasketDeletion = taskService.newTask(wbId);

View File

@ -8,6 +8,7 @@ import java.util.ArrayList;
import java.util.List;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.BulkOperationResults;
@ -60,9 +61,11 @@ class DeleteTaskAccTest extends AbstractAccTest {
assertThatThrownBy(call).isInstanceOf(TaskNotFoundException.class);
}
@WithAccessId(user = "businessadmin")
@WithAccessId(user = "taskadmin")
@Test
void should_ThrowException_When_UserIsTaskAdminAndNotAuthorizedToDeleteTask() {
@WithAccessId(user = "user_1_1")
@TestTemplate
void should_ThrowException_When_UserIsNotInAdminRole() {
TaskService taskService = taskanaEngine.getTaskService();

View File

@ -4,9 +4,11 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import acceptance.AbstractAccTest;
import java.sql.SQLException;
import java.util.List;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.InvalidArgumentException;
@ -29,7 +31,7 @@ public class DeleteTaskCommentAccTest extends AbstractAccTest {
@Test
void should_DeleteTaskComment_For_TaskCommentId()
throws TaskCommentNotFoundException, NotAuthorizedException, TaskNotFoundException,
InvalidArgumentException {
InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
@ -67,11 +69,14 @@ public class DeleteTaskCommentAccTest extends AbstractAccTest {
assertThat(taskCommentsAfterDeletion).hasSize(3);
}
@WithAccessId(user = "admin")
@WithAccessId(user = "taskadmin")
@Test
void should_DeleteTaskComment_When_NoExplicitPermissionsButUserIsInTaskAdminRole()
@TestTemplate
void should_DeleteTaskComment_When_NoExplicitPermissionsButUserIsInAdministrativeRole()
throws NotAuthorizedException, TaskNotFoundException, TaskCommentNotFoundException,
InvalidArgumentException {
InvalidArgumentException, SQLException {
resetDb(false);
TaskService taskService = taskanaEngine.getTaskService();

View File

@ -7,6 +7,7 @@ import acceptance.AbstractAccTest;
import java.util.HashMap;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.InvalidArgumentException;
@ -18,7 +19,9 @@ import pro.taskana.task.api.TaskState;
import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.task.api.models.Task;
/** Acceptance test for all "get task" scenarios. */
/**
* Acceptance test for all "get task" scenarios.
*/
@ExtendWith(JaasExtension.class)
class GetTaskAccTest extends AbstractAccTest {
@ -107,9 +110,10 @@ class GetTaskAccTest extends AbstractAccTest {
assertThatThrownBy(getTaskCall).isInstanceOf(NotAuthorizedException.class);
}
@WithAccessId(user = "admin")
@WithAccessId(user = "taskadmin")
@Test
void should_ReturnTask_When_NoExplicitPermissionsButUserIsInTaskAdminRole()
@TestTemplate
void should_ReturnTask_When_NoExplicitPermissionsButUserIsInAdministrativeRole()
throws NotAuthorizedException, TaskNotFoundException {
TaskService taskService = taskanaEngine.getTaskService();

View File

@ -9,6 +9,7 @@ import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
@ -44,7 +45,8 @@ class TerminateTaskAccTest extends AbstractAccTest {
}
@WithAccessId(user = "admin", groups = "group_1")
@Test
@WithAccessId(user = "taskadmin")
@TestTemplate
void should_TerminateTask_When_TaskStateIsReady()
throws NotAuthorizedException, TaskNotFoundException, InvalidStateException {
List<TaskSummary> taskSummaries = taskService.createTaskQuery().stateIn(TaskState.READY).list();
@ -56,8 +58,9 @@ class TerminateTaskAccTest extends AbstractAccTest {
assertThat(numTasks).isEqualTo(6);
}
@WithAccessId(user = "taskadmin", groups = "group_1")
@Test
@WithAccessId(user = "admin", groups = "group_1")
@WithAccessId(user = "taskadmin")
@TestTemplate
void should_TerminateTask_When_TaskStateIsClaimed()
throws NotAuthorizedException, TaskNotFoundException, InvalidStateException {
List<TaskSummary> taskSummaries =
@ -87,7 +90,7 @@ class TerminateTaskAccTest extends AbstractAccTest {
@WithAccessId(user = "user_1_2")
@Test
void should_ThrowException_When_UserIsNotAdmin() {
void should_ThrowException_When_UserIsNotInAdministrativeRole() {
ThrowingCallable taskanaCall =
() -> taskService.terminateTask("TKI:000000000000000000000000000000000000");

View File

@ -1,6 +1,7 @@
package acceptance.task;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import acceptance.AbstractAccTest;
@ -11,6 +12,7 @@ import java.util.Collections;
import java.util.List;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.BulkOperationResults;
@ -57,10 +59,10 @@ class TransferTaskAccTest extends AbstractAccTest {
assertThat(transferredTask.getState()).isEqualTo(TaskState.READY);
}
@WithAccessId(
user = "taskadmin")
@Test
void should_TransferTask_When_NoExplicitPermissionsButUserIsInTaskAdminRole()
@WithAccessId(user = "admin")
@WithAccessId(user = "taskadmin")
@TestTemplate
void should_TransferTask_When_NoExplicitPermissionsButUserIsInAdministrativeRole()
throws NotAuthorizedException, WorkbasketNotFoundException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
@ -302,7 +304,12 @@ class TransferTaskAccTest extends AbstractAccTest {
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException {
TaskService taskService = taskanaEngine.getTaskService();
List<String> taskIds = Collections.singletonList("TKI:000000000000000000000000000000000006");
taskService.transferTasks("WBI:100000000000000000000000000000000006", taskIds);
ThrowingCallable call = () -> {
taskService.transferTasks("WBI:100000000000000000000000000000000006", taskIds);
};
assertThatCode(call).doesNotThrowAnyException();
}
@WithAccessId(user = "teamlead_1", groups = "group_1")

View File

@ -11,6 +11,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.classification.api.exceptions.ClassificationNotFoundException;
@ -129,6 +130,31 @@ class UpdateTaskAccTest extends AbstractAccTest {
.withFailMessage("The task has already been updated by another user");
}
@WithAccessId(user = "admin")
@WithAccessId(user = "taskadmin")
@TestTemplate
void should_UpdateTask_When_NoExplicitPermissionsButUserIsInAdministrativeRole()
throws TaskNotFoundException, ClassificationNotFoundException, InvalidArgumentException,
ConcurrencyException, NotAuthorizedException, AttachmentPersistenceException,
InvalidStateException, SQLException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000000");
final ClassificationSummary classificationSummary = task.getClassificationSummary();
task.setClassificationKey("T2100");
Task updatedTask = taskService.updateTask(task);
updatedTask = taskService.getTask(updatedTask.getId());
assertThat(updatedTask).isNotNull();
assertThat(updatedTask.getClassificationSummary().getKey()).isEqualTo("T2100");
assertThat(updatedTask.getClassificationSummary()).isNotEqualTo(classificationSummary);
assertThat(updatedTask.getCreated()).isNotEqualTo(updatedTask.getModified());
assertThat(task.getPlanned()).isEqualTo(updatedTask.getPlanned());
assertThat(task.getName()).isEqualTo(updatedTask.getName());
assertThat(task.getDescription()).isEqualTo(updatedTask.getDescription());
resetDb(false); // classification of task TKI:0..00 was changed...
}
@WithAccessId(user = "user_1_1", groups = "group_1")
@Test
void should_UpdateTaskProperties_When_ClassificationOfTaskIsChanged()

View File

@ -7,6 +7,7 @@ import acceptance.AbstractAccTest;
import java.util.List;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.DomainNotFoundException;
@ -62,9 +63,10 @@ class CreateWorkbasketAccTest extends AbstractAccTest {
assertThat(createdWorkbasket2).isEqualTo(createdWorkbasket);
}
@WithAccessId(user = "dummy")
@Test
void testCreateWorkbasketNotAuthorized() {
@WithAccessId(user = "user_1_1")
@WithAccessId(user = "taskadmin")
@TestTemplate
void should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdmin() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.newWorkbasket("key3", "DOMAIN_A");
@ -76,20 +78,6 @@ class CreateWorkbasketAccTest extends AbstractAccTest {
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
}
@WithAccessId(user = "taskadmin")
@Test
void should_ThrowException_When_UserIsTaskAdminAndNotAuthorizedToCreateWorkbasket() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.newWorkbasket("NT1234", "DOMAIN_A");
workbasket.setName("new workbasket");
workbasket.setType(WorkbasketType.GROUP);
workbasket.setOrgLevel1("company");
ThrowingCallable createWorkbasketCall = () -> workbasketService.createWorkbasket(workbasket);
assertThatThrownBy(createWorkbasketCall).isInstanceOf(NotAuthorizedException.class);
}
@WithAccessId(
user = "teamlead_1",
groups = {"group_1", "businessadmin"})

View File

@ -0,0 +1,39 @@
package acceptance.workbasket;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import acceptance.AbstractAccTest;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.security.JaasExtension;
import pro.taskana.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
/**
* Acceptance test for all "set workbasket access item" scenarios.
*/
@ExtendWith(JaasExtension.class)
public class CreateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
@WithAccessId(user = "user_1_1")
@WithAccessId(user = "taskadmin")
@TestTemplate
void should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdmin() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
WorkbasketAccessItem accessItem =
workbasketService.newWorkbasketAccessItem(
"WBI:100000000000000000000000000000000001", "user1");
accessItem.setPermAppend(true);
accessItem.setPermCustom11(true);
accessItem.setPermRead(true);
ThrowingCallable call = () -> {
workbasketService.createWorkbasketAccessItem(accessItem);
};
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
}
}

View File

@ -8,6 +8,7 @@ import java.util.List;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.InvalidArgumentException;
@ -26,7 +27,9 @@ import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
import pro.taskana.workbasket.api.models.Workbasket;
import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
/** Acceptance test which does test the deletion of a workbasket and all wanted failures. */
/**
* Acceptance test which does test the deletion of a workbasket and all wanted failures.
*/
@ExtendWith(JaasExtension.class)
class DeleteWorkbasketAccTest extends AbstractAccTest {
@ -56,21 +59,9 @@ class DeleteWorkbasketAccTest extends AbstractAccTest {
}
@WithAccessId(user = "elena")
@Test
void testDeleteWorkbasketNotAuthorized() {
ThrowingCallable call =
() -> {
Workbasket wb = workbasketService.getWorkbasket("TEAMLEAD_2", "DOMAIN_A");
workbasketService.deleteWorkbasket(wb.getId());
};
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
}
@WithAccessId(user = "taskadmin")
@Test
void
should_ThrowException_When_UserIsTaskAdminAndNotAuthorizedToDeleteWorkbasketByKeyAndDomain() {
@TestTemplate
void should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdmin() {
ThrowingCallable deleteWorkbasketCall =
() -> {
@ -78,13 +69,8 @@ class DeleteWorkbasketAccTest extends AbstractAccTest {
workbasketService.deleteWorkbasket(wb.getId());
};
assertThatThrownBy(deleteWorkbasketCall).isInstanceOf(NotAuthorizedException.class);
}
@WithAccessId(user = "taskadmin")
@Test
void should_ThrowException_When_UserIsTaskAdminAndNotAuthorizedToDeleteWorkbasketById() {
ThrowingCallable deleteWorkbasketCall =
deleteWorkbasketCall =
() -> {
Workbasket wb =
workbasketService.getWorkbasket("WBI:100000000000000000000000000000000005");
@ -181,7 +167,7 @@ class DeleteWorkbasketAccTest extends AbstractAccTest {
@Test
void testCascadingDeleteOfAccessItems()
throws WorkbasketNotFoundException, NotAuthorizedException, InvalidArgumentException,
WorkbasketAccessItemAlreadyExistException {
WorkbasketAccessItemAlreadyExistException {
Workbasket wb = workbasketService.getWorkbasket("WBI:100000000000000000000000000000000008");
String wbId = wb.getId();
// create 2 access Items
@ -215,8 +201,8 @@ class DeleteWorkbasketAccTest extends AbstractAccTest {
@Test
void testMarkWorkbasketForDeletion()
throws WorkbasketInUseException, NotAuthorizedException, WorkbasketNotFoundException,
InvalidArgumentException, InvalidOwnerException, InvalidStateException,
TaskNotFoundException {
InvalidArgumentException, InvalidOwnerException, InvalidStateException,
TaskNotFoundException {
final Workbasket wb =
workbasketService.getWorkbasket("WBI:100000000000000000000000000000000006");

View File

@ -0,0 +1,51 @@
package acceptance.workbasket;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import acceptance.AbstractAccTest;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.security.JaasExtension;
import pro.taskana.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketService;
import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
/**
* Acceptance test for all "delete workbasket authorizations" scenarios.
*/
@ExtendWith(JaasExtension.class)
public class DeleteWorkbasketAuthorizationsAccTest extends AbstractAccTest {
@WithAccessId(user = "user_1_1")
@WithAccessId(user = "taskadmin")
@TestTemplate
public void should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdmin() {
final WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
ThrowingCallable deleteWorkbasketAccessItemCall =
() -> {
workbasketService.deleteWorkbasketAccessItemsForAccessId("group_1");
};
assertThatThrownBy(deleteWorkbasketAccessItemCall).isInstanceOf(NotAuthorizedException.class);
WorkbasketAccessItem workbasketAccessItem =
workbasketService.newWorkbasketAccessItem(
"WBI:100000000000000000000000000000000008", "newAccessIdForUpdate");
workbasketAccessItem.setPermCustom1(true);
deleteWorkbasketAccessItemCall =
() -> {
workbasketService.deleteWorkbasketAccessItem(workbasketAccessItem.getId());
};
assertThatThrownBy(deleteWorkbasketAccessItemCall).isInstanceOf(NotAuthorizedException.class);
}
}

View File

@ -13,6 +13,7 @@ import java.util.List;
import java.util.stream.Collectors;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
@ -109,9 +110,10 @@ class DistributionTargetsAccTest extends AbstractAccTest {
assertThat(beforeCount).isEqualTo(afterCount);
}
@WithAccessId(user = "user_3_1", groups = "group_1")
@Test
void testDistributionTargetCallsFailWithNotAuthorizedException() {
@WithAccessId(user = "user_1_1", groups = "group_1")
@WithAccessId(user = "taskadmin")
@TestTemplate
void should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdminAndMakesDistTargetCalls() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
String existingWb = "WBI:100000000000000000000000000000000001";
@ -308,62 +310,6 @@ class DistributionTargetsAccTest extends AbstractAccTest {
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
}
@WithAccessId(user = "taskadmin")
@Test
void should_ThrowException_When_UserIsTaskAdminAndNotAuthorizedToGetWorkbasketDistTargets() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
ThrowingCallable retrieveWorkbasketDistributionTargetsCall =
() -> {
List<WorkbasketSummary> ws =
workbasketService.getDistributionSources("WBI:100000000000000000000000000000000004");
};
assertThatThrownBy(retrieveWorkbasketDistributionTargetsCall)
.isInstanceOf(NotAuthorizedException.class);
}
@WithAccessId(user = "taskadmin")
@Test
void should_ThrowException_When_UserIsTaskAdminAndNotAuthorizedToSetWorkbasketDistTargets() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
ThrowingCallable call =
() -> {
workbasketService.setDistributionTargets(
"WBI:100000000000000000000000000000000004",
Arrays.asList("WBI:100000000000000000000000000000000002"));
};
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
}
@WithAccessId(user = "taskadmin")
@Test
void should_ThrowException_When_UserIsTaskAdminAndNotAuthorizedToAddWorkbasketDistTarget() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
ThrowingCallable call =
() -> {
workbasketService.addDistributionTarget(
"WBI:100000000000000000000000000000000004",
"WBI:100000000000000000000000000000000002");
};
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
}
@WithAccessId(user = "taskadmin")
@Test
void should_ThrowException_When_UserIsTaskAdminAndNotAuthorizedToRemoveWorkbasketDistTarget() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
ThrowingCallable call =
() -> {
workbasketService.removeDistributionTarget(
"WBI:100000000000000000000000000000000004",
"WBI:100000000000000000000000000000000002");
};
assertThatThrownBy(call).isInstanceOf(NotAuthorizedException.class);
}
@WithAccessId(
user = "user_2_2",
groups = {"group_1", "group_2"})

View File

@ -7,6 +7,7 @@ import acceptance.AbstractAccTest;
import java.util.List;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
@ -51,9 +52,12 @@ class GetWorkbasketAccTest extends AbstractAccTest {
assertThat(workbasket.getCustom4()).isEqualTo("custom4");
}
@WithAccessId(user = "admin")
@WithAccessId(user = "businessadmin")
@WithAccessId(user = "taskadmin")
@Test
void should_ReturnWorkbasketByKeyAndDomain_When_NoExplicitPermissionsButUserIsInTaskAdminRole()
@TestTemplate
void should_ReturnWorkbasketByKeyAndDomain_When_NoExplicitPermissionButUserHasAdministrativeRole()
throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
@ -65,9 +69,11 @@ class GetWorkbasketAccTest extends AbstractAccTest {
assertThat(retrievedWorkbasket.getOwner()).isEqualTo("Peter Maier");
}
@WithAccessId(user = "admin")
@WithAccessId(user = "businessadmin")
@WithAccessId(user = "taskadmin")
@Test
void should_ReturnWorkbasketById_When_NoExplicitPermissionsButUserIsInTaskAdminRole()
@TestTemplate
void should_ReturnWorkbasketById_When_NoExplicitPermissionsButUserIsInAdministrativeRole()
throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();

View File

@ -0,0 +1,35 @@
package acceptance.workbasket;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import acceptance.AbstractAccTest;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.security.JaasExtension;
import pro.taskana.security.WithAccessId;
import pro.taskana.workbasket.api.WorkbasketService;
/**
* Acceptance test for all "get workbasket authorizations" scenarios.
*/
@ExtendWith(JaasExtension.class)
public class GetWorkbasketAuthorizationsAccTest extends AbstractAccTest {
@WithAccessId(user = "user_1_1")
@WithAccessId(user = "taskadmin")
@TestTemplate
public void should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdmin() {
final WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
ThrowingCallable retrieveWorkbasketAccessItemCall =
() -> {
workbasketService.getWorkbasketAccessItems("WBI:100000000000000000000000000000000008");
};
assertThatThrownBy(retrieveWorkbasketAccessItemCall).isInstanceOf(NotAuthorizedException.class);
}
}

View File

@ -8,6 +8,7 @@ import acceptance.AbstractAccTest;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.common.api.exceptions.ConcurrencyException;
@ -20,7 +21,9 @@ import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
import pro.taskana.workbasket.api.models.Workbasket;
import pro.taskana.workbasket.internal.models.WorkbasketImpl;
/** Acceptance test for all "update workbasket" scenarios. */
/**
* Acceptance test for all "update workbasket" scenarios.
*/
@ExtendWith(JaasExtension.class)
public class UpdateWorkbasketAccTest extends AbstractAccTest {
@ -100,8 +103,9 @@ public class UpdateWorkbasketAccTest extends AbstractAccTest {
}
@WithAccessId(user = "user_1_1", groups = "group_1")
@Test
public void testCheckAuthorizationToUpdateWorkbasket()
@WithAccessId(user = "taskadmin")
@TestTemplate
public void should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdmin()
throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("USER_1_1", "DOMAIN_A");
@ -111,18 +115,4 @@ public class UpdateWorkbasketAccTest extends AbstractAccTest {
assertThatThrownBy(() -> workbasketService.updateWorkbasket(workbasket))
.isInstanceOf(NotAuthorizedException.class);
}
@WithAccessId(user = "taskadmin")
@Test
public void should_ThrowException_When_UserIsTaskAdminAndNotAuthorizedToUpdateWorkbasket()
throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("USER_1_1", "DOMAIN_A");
workbasket.setName("updated workbasket name");
assertThatThrownBy(() -> workbasketService.updateWorkbasket(workbasket))
.isInstanceOf(NotAuthorizedException.class);
}
}

View File

@ -9,6 +9,7 @@ import java.util.HashSet;
import java.util.List;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import pro.taskana.classification.api.exceptions.ClassificationNotFoundException;
@ -29,7 +30,7 @@ import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
import pro.taskana.workbasket.internal.models.WorkbasketAccessItemImpl;
/**
* Acceptance test for all "update workbasket" scenarios.
* Acceptance test for all "update workbasket authorizations" scenarios.
*/
@ExtendWith(JaasExtension.class)
class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
@ -38,57 +39,10 @@ class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
super();
}
@WithAccessId(user = "user_1_1")
@WithAccessId(user = "taskadmin")
@Test
public void should_ThrowException_When_TaskAdminTriesToGetWorkbasketAccItem() {
final WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
ThrowingCallable retrieveWorkbasketAccessItemCall =
() -> {
workbasketService.getWorkbasketAccessItems("WBI:100000000000000000000000000000000008");
};
assertThatThrownBy(retrieveWorkbasketAccessItemCall).isInstanceOf(NotAuthorizedException.class);
}
@WithAccessId(user = "taskadmin")
@Test
public void should_ThrowException_When_TaskAdminTriesToDeleteWorkbasketAccItemById() {
final WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
ThrowingCallable deleteWorkbasketAccessItemCall =
() -> {
workbasketService.deleteWorkbasketAccessItemsForAccessId("group_1");
};
assertThatThrownBy(deleteWorkbasketAccessItemCall).isInstanceOf(NotAuthorizedException.class);
}
@WithAccessId(user = "taskadmin")
@Test
public void should_ThrowException_When_TaskAdminTriesToDeleteWorkbasketAccessItemByAccessId() {
final WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
WorkbasketAccessItem workbasketAccessItem =
workbasketService.newWorkbasketAccessItem(
"WBI:100000000000000000000000000000000008", "newAccessIdForUpdate");
workbasketAccessItem.setPermCustom1(true);
ThrowingCallable deleteWorkbasketAccessItemCall =
() -> {
workbasketService.deleteWorkbasketAccessItem(workbasketAccessItem.getId());
};
assertThatThrownBy(deleteWorkbasketAccessItemCall).isInstanceOf(NotAuthorizedException.class);
}
@WithAccessId(user = "taskadmin")
@Test
public void should_ThrowException_When_TaskAdminTriesToUpdateWorkbasketAccItem() {
@TestTemplate
public void should_ThrowException_When_UserIsNotAdminOrBusinessAdmin() {
final WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();