Search in sources :

Example 66 with WorkbasketService

use of pro.taskana.WorkbasketService 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 67 with WorkbasketService

use of pro.taskana.WorkbasketService 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 68 with WorkbasketService

use of pro.taskana.WorkbasketService 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 69 with WorkbasketService

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

the class DeleteWorkbasketAccTest method testCreateAndDeleteWorkbasket.

@WithAccessId(userName = "user_1_2", groupNames = { "businessadmin" })
@Test
public void testCreateAndDeleteWorkbasket() throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    int before = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size();
    Workbasket workbasket = workbasketService.newWorkbasket("NT1234", "DOMAIN_A");
    workbasket.setName("TheUltimate");
    workbasket.setType(WorkbasketType.GROUP);
    workbasket.setOrgLevel1("company");
    workbasket = workbasketService.createWorkbasket(workbasket);
    try {
        workbasketService.deleteWorkbasket(workbasket.getId());
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) Workbasket(pro.taskana.Workbasket) WorkbasketAlreadyExistException(pro.taskana.exceptions.WorkbasketAlreadyExistException) WorkbasketInUseException(pro.taskana.exceptions.WorkbasketInUseException) DomainNotFoundException(pro.taskana.exceptions.DomainNotFoundException) InvalidWorkbasketException(pro.taskana.exceptions.InvalidWorkbasketException) InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) WorkbasketNotFoundException(pro.taskana.exceptions.WorkbasketNotFoundException) SQLException(java.sql.SQLException) NotAuthorizedException(pro.taskana.exceptions.NotAuthorizedException) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 70 with WorkbasketService

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

the class GetWorkbasketAccTest method testGetWorkbasket.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testGetWorkbasket() throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, InvalidWorkbasketException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    Workbasket workbasket = workbasketService.getWorkbasket("WBI:100000000000000000000000000000000007");
    Assert.assertEquals("DOMAIN_A", workbasket.getDomain());
    Assert.assertEquals("PPK User 2 KSC 1", workbasket.getDescription());
    Assert.assertEquals("PPK User 2 KSC 1", workbasket.getName());
    Assert.assertEquals("USER_1_2", workbasket.getKey());
    Assert.assertEquals(WorkbasketType.PERSONAL, workbasket.getType());
    Assert.assertEquals("Peter Maier", workbasket.getOwner());
    Assert.assertEquals("Versicherung", workbasket.getOrgLevel1());
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) Workbasket(pro.taskana.Workbasket) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Aggregations

AbstractAccTest (acceptance.AbstractAccTest)84 Test (org.junit.Test)84 WorkbasketService (pro.taskana.WorkbasketService)84 WithAccessId (pro.taskana.security.WithAccessId)78 WorkbasketSummary (pro.taskana.WorkbasketSummary)52 Workbasket (pro.taskana.Workbasket)12 WorkbasketAccessItem (pro.taskana.WorkbasketAccessItem)11 ArrayList (java.util.ArrayList)8 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)7 InvalidWorkbasketException (pro.taskana.exceptions.InvalidWorkbasketException)5 WorkbasketNotFoundException (pro.taskana.exceptions.WorkbasketNotFoundException)5 SQLException (java.sql.SQLException)4 Task (pro.taskana.Task)4 TaskService (pro.taskana.TaskService)4 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)4 List (java.util.List)3 Assert.assertTrue (org.junit.Assert.assertTrue)3 Assert.fail (org.junit.Assert.fail)3 Ignore (org.junit.Ignore)3 RunWith (org.junit.runner.RunWith)3