Search in sources :

Example 21 with WorkbasketAccessItem

use of pro.taskana.WorkbasketAccessItem in project taskana by Taskana.

the class UpdateWorkbasketAuthorizationsAccTest method testUpdateWorkbasketAccessItemRejected.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test
public void testUpdateWorkbasketAccessItemRejected() throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, InvalidWorkbasketException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1000000000000000000000000000000000000000", "user1");
    accessItem.setPermAppend(true);
    accessItem.setPermCustom11(true);
    accessItem.setPermRead(true);
    accessItem = workbasketService.createWorkbasketAccessItem(accessItem);
    accessItem.setPermCustom1(true);
    accessItem.setPermAppend(false);
    ((WorkbasketAccessItemImpl) accessItem).setAccessId("willi");
    try {
        workbasketService.updateWorkbasketAccessItem(accessItem);
        fail("InvalidArgumentException was expected because access id was changed");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
    ((WorkbasketAccessItemImpl) accessItem).setAccessId("user1");
    accessItem = workbasketService.updateWorkbasketAccessItem(accessItem);
    Assert.assertEquals(false, accessItem.isPermAppend());
    Assert.assertEquals(true, accessItem.isPermRead());
    Assert.assertEquals(true, accessItem.isPermCustom11());
    Assert.assertEquals(true, accessItem.isPermCustom1());
    Assert.assertEquals(false, accessItem.isPermCustom2());
    ((WorkbasketAccessItemImpl) accessItem).setWorkbasketId("2");
    try {
        workbasketService.updateWorkbasketAccessItem(accessItem);
        fail("InvalidArgumentException was expected because key was changed");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) WorkbasketAccessItem(pro.taskana.WorkbasketAccessItem) WorkbasketAccessItemImpl(pro.taskana.impl.WorkbasketAccessItemImpl) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 22 with WorkbasketAccessItem

use of pro.taskana.WorkbasketAccessItem in project taskana by Taskana.

the class UpdateWorkbasketAuthorizationsAccTest method testUpdatedAccessItemLeadsToNotAuthorizedException.

@WithAccessId(userName = "user_1_1", groupNames = { "group_2", "businessadmin" })
@Test
public void testUpdatedAccessItemLeadsToNotAuthorizedException() throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, ClassificationNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
    TaskService taskService = taskanaEngine.getTaskService();
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    String wbKey = "USER_2_1";
    String wbDomain = "DOMAIN_A";
    String groupName = "group_2";
    Task newTask = taskService.newTask(wbKey, wbDomain);
    newTask.setClassificationKey("T2100");
    newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
    Task createdTask = taskService.createTask(newTask);
    List<TaskSummary> tasks = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain(wbKey, wbDomain)).list();
    Assert.assertEquals(1, tasks.size());
    assertThat(createdTask, not(equalTo(null)));
    List<WorkbasketAccessItem> accessItems = workbasketService.getWorkbasketAccessItems("WBI:100000000000000000000000000000000008");
    WorkbasketAccessItem theAccessItem = accessItems.stream().filter(x -> groupName.equals(x.getAccessId())).findFirst().orElse(null);
    Assert.assertTrue(theAccessItem != null);
    theAccessItem.setPermOpen(false);
    workbasketService.updateWorkbasketAccessItem(theAccessItem);
    try {
        taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain(wbKey, wbDomain)).list();
        fail("NotAuthorizedToQueryWorkbasketException was expected ");
    } catch (NotAuthorizedToQueryWorkbasketException ignored) {
    // nothing to do
    }
}
Also used : Task(pro.taskana.Task) WorkbasketService(pro.taskana.WorkbasketService) TaskService(pro.taskana.TaskService) WorkbasketAccessItem(pro.taskana.WorkbasketAccessItem) TaskSummary(pro.taskana.TaskSummary) NotAuthorizedToQueryWorkbasketException(pro.taskana.exceptions.NotAuthorizedToQueryWorkbasketException) KeyDomain(pro.taskana.KeyDomain) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 23 with WorkbasketAccessItem

use of pro.taskana.WorkbasketAccessItem in project taskana by Taskana.

the class UpdateWorkbasketAuthorizationsAccTest method testUpdatedAccessItemList.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test
public void testUpdatedAccessItemList() throws InvalidArgumentException, NotAuthorizedException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    final String wbId = "WBI:100000000000000000000000000000000004";
    List<WorkbasketAccessItem> accessItems = workbasketService.getWorkbasketAccessItems(wbId);
    int countBefore = accessItems.size();
    // update some values
    WorkbasketAccessItem item0 = accessItems.get(0);
    item0.setPermAppend(false);
    item0.setPermOpen(false);
    item0.setPermTransfer(false);
    final String updateId0 = item0.getId();
    WorkbasketAccessItem item1 = accessItems.get(1);
    item1.setPermAppend(false);
    item1.setPermOpen(false);
    item1.setPermTransfer(false);
    final String updateId1 = item1.getId();
    workbasketService.setWorkbasketAccessItems(wbId, accessItems);
    List<WorkbasketAccessItem> updatedAccessItems = workbasketService.getWorkbasketAccessItems(wbId);
    int countAfter = updatedAccessItems.size();
    assertThat(countAfter, equalTo(countBefore));
    item0 = updatedAccessItems.stream().filter(i -> i.getId().equals(updateId0)).findFirst().get();
    assertFalse(item0.isPermAppend());
    assertFalse(item0.isPermOpen());
    assertFalse(item0.isPermTransfer());
    item1 = updatedAccessItems.stream().filter(i -> i.getId().equals(updateId1)).findFirst().get();
    assertFalse(item1.isPermAppend());
    assertFalse(item1.isPermOpen());
    assertFalse(item1.isPermTransfer());
}
Also used : NotAuthorizedToQueryWorkbasketException(pro.taskana.exceptions.NotAuthorizedToQueryWorkbasketException) WithAccessId(pro.taskana.security.WithAccessId) IsEqual.equalTo(org.hamcrest.core.IsEqual.equalTo) RunWith(org.junit.runner.RunWith) WorkbasketService(pro.taskana.WorkbasketService) CurrentUserContext(pro.taskana.security.CurrentUserContext) Assert.assertThat(org.junit.Assert.assertThat) WorkbasketNotFoundException(pro.taskana.exceptions.WorkbasketNotFoundException) SQLException(java.sql.SQLException) JAASRunner(pro.taskana.security.JAASRunner) Task(pro.taskana.Task) Assert.fail(org.junit.Assert.fail) KeyDomain(pro.taskana.KeyDomain) WorkbasketAccessItem(pro.taskana.WorkbasketAccessItem) IsNot.not(org.hamcrest.core.IsNot.not) TaskAlreadyExistException(pro.taskana.exceptions.TaskAlreadyExistException) TaskSummary(pro.taskana.TaskSummary) ClassificationNotFoundException(pro.taskana.exceptions.ClassificationNotFoundException) AbstractAccTest(acceptance.AbstractAccTest) Assert.assertTrue(org.junit.Assert.assertTrue) InvalidWorkbasketException(pro.taskana.exceptions.InvalidWorkbasketException) Test(org.junit.Test) WorkbasketAccessItemImpl(pro.taskana.impl.WorkbasketAccessItemImpl) InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) TaskService(pro.taskana.TaskService) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) NotAuthorizedException(pro.taskana.exceptions.NotAuthorizedException) Assert(org.junit.Assert) WorkbasketService(pro.taskana.WorkbasketService) WorkbasketAccessItem(pro.taskana.WorkbasketAccessItem) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 24 with WorkbasketAccessItem

use of pro.taskana.WorkbasketAccessItem in project taskana by Taskana.

the class WorkbasketAccessItemMapperTest method workBasketAccessItemToModelPropertiesEqual.

@Test
public void workBasketAccessItemToModelPropertiesEqual() {
    // given
    WorkbasketAccessItemResource resource = new WorkbasketAccessItemResource();
    resource.setAccessId("10");
    resource.setAccessItemId("120");
    resource.setWorkbasketId("1");
    resource.setPermRead(true);
    resource.setPermAppend(false);
    resource.setPermDistribute(false);
    resource.setPermOpen(false);
    resource.setPermTransfer(true);
    resource.setPermCustom1(false);
    resource.setPermCustom2(false);
    resource.setPermCustom3(false);
    resource.setPermCustom4(false);
    resource.setPermCustom5(true);
    resource.setPermCustom6(false);
    resource.setPermCustom7(false);
    resource.setPermCustom8(false);
    resource.setPermCustom9(false);
    resource.setPermCustom10(false);
    resource.setPermCustom11(true);
    resource.setPermCustom12(false);
    // when
    WorkbasketAccessItem accessItem = workbasketAccessItemMapper.toModel(resource);
    // then
    testEquality(accessItem, resource);
}
Also used : WorkbasketAccessItemResource(pro.taskana.rest.resource.WorkbasketAccessItemResource) WorkbasketAccessItem(pro.taskana.WorkbasketAccessItem) Test(org.junit.Test)

Example 25 with WorkbasketAccessItem

use of pro.taskana.WorkbasketAccessItem in project taskana by Taskana.

the class WorkbasketAccessItemMapperTest method workBasketAccessItemToResourcePropertiesEqual.

@Test
public void workBasketAccessItemToResourcePropertiesEqual() throws NotAuthorizedException, WorkbasketNotFoundException {
    // given
    WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "2");
    accessItem.setPermDistribute(false);
    accessItem.setPermOpen(true);
    accessItem.setPermAppend(false);
    accessItem.setPermRead(false);
    accessItem.setPermTransfer(true);
    accessItem.setPermCustom1(false);
    accessItem.setPermCustom2(false);
    accessItem.setPermCustom3(true);
    accessItem.setPermCustom4(true);
    accessItem.setPermCustom5(true);
    accessItem.setPermCustom6(true);
    accessItem.setPermCustom7(true);
    accessItem.setPermCustom8(true);
    accessItem.setPermCustom9(true);
    accessItem.setPermCustom10(true);
    accessItem.setPermCustom11(true);
    accessItem.setPermCustom12(true);
    // when
    WorkbasketAccessItemResource resource = workbasketAccessItemMapper.toResource(accessItem);
    // then
    testEquality(accessItem, resource);
}
Also used : WorkbasketAccessItemResource(pro.taskana.rest.resource.WorkbasketAccessItemResource) WorkbasketAccessItem(pro.taskana.WorkbasketAccessItem) Test(org.junit.Test)

Aggregations

WorkbasketAccessItem (pro.taskana.WorkbasketAccessItem)31 Test (org.junit.Test)18 WithAccessId (pro.taskana.security.WithAccessId)16 AbstractAccTest (acceptance.AbstractAccTest)11 WorkbasketService (pro.taskana.WorkbasketService)11 ArrayList (java.util.ArrayList)6 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)6 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)5 WorkbasketAccessItemResource (pro.taskana.rest.resource.WorkbasketAccessItemResource)5 Task (pro.taskana.Task)4 Connection (java.sql.Connection)3 KeyDomain (pro.taskana.KeyDomain)3 TaskService (pro.taskana.TaskService)3 TaskSummary (pro.taskana.TaskSummary)3 InvalidWorkbasketException (pro.taskana.exceptions.InvalidWorkbasketException)3 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)3 NotAuthorizedToQueryWorkbasketException (pro.taskana.exceptions.NotAuthorizedToQueryWorkbasketException)3 WorkbasketNotFoundException (pro.taskana.exceptions.WorkbasketNotFoundException)3 WorkbasketAccessItemImpl (pro.taskana.impl.WorkbasketAccessItemImpl)3 SQLException (java.sql.SQLException)2