Search in sources :

Example 16 with Workbasket

use of pro.taskana.Workbasket 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;
    }
}
Also used : WorkbasketPermission(pro.taskana.WorkbasketPermission) NotAuthorizedException(pro.taskana.exceptions.NotAuthorizedException) Workbasket(pro.taskana.Workbasket) Test(org.junit.Test)

Example 17 with Workbasket

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

the class DeleteWorkbasketAccTest method testDeleteWorkbasketWhichIsUsed.

@WithAccessId(userName = "user_1_1", groupNames = { "businessadmin" })
@Test(expected = WorkbasketInUseException.class)
public void testDeleteWorkbasketWhichIsUsed() throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
    // all rights, DOMAIN_A with Tasks
    Workbasket wb = workbasketService.getWorkbasket("USER_1_1", "DOMAIN_A");
    workbasketService.deleteWorkbasket(wb.getId());
}
Also used : Workbasket(pro.taskana.Workbasket) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 18 with Workbasket

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

the class DistributionTargetsAccTest method testAddDistributionTargetsFailsNotAuthorized.

@WithAccessId(userName = "user_2_2", groupNames = { "group_1", "group_2" })
@Test(expected = NotAuthorizedException.class)
public void testAddDistributionTargetsFailsNotAuthorized() throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    Workbasket workbasket = workbasketService.getWorkbasket("GPK_KSC_1", "DOMAIN_A");
    List<WorkbasketSummary> distributionTargets = workbasketService.getDistributionTargets(workbasket.getId());
    assertEquals(4, distributionTargets.size());
    // add a new distribution target
    Workbasket newTarget = workbasketService.getWorkbasket("GPK_B_KSC_2", "DOMAIN_B");
    workbasketService.addDistributionTarget(workbasket.getId(), newTarget.getId());
    fail("NotAuthorizedException should have been thrown");
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) Workbasket(pro.taskana.Workbasket) WorkbasketSummary(pro.taskana.WorkbasketSummary) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 19 with Workbasket

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

the class UpdateWorkbasketAccTest method testUpdateWorkbasket.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test
public void testUpdateWorkbasket() throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, InvalidWorkbasketException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    Workbasket workbasket = workbasketService.getWorkbasket("GPK_KSC", "DOMAIN_A");
    Instant modified = workbasket.getModified();
    workbasket.setName("new name");
    workbasket.setDescription("new description");
    workbasket.setType(WorkbasketType.TOPIC);
    workbasket.setOrgLevel1("new level 1");
    workbasket.setOrgLevel2("new level 2");
    workbasket.setOrgLevel3("new level 3");
    workbasket.setOrgLevel4("new level 4");
    workbasket.setCustom1("new custom 1");
    workbasket.setCustom2("new custom 2");
    workbasket.setCustom3("new custom 3");
    workbasket.setCustom4("new custom 4");
    workbasket.setDescription("new description");
    workbasketService.updateWorkbasket(workbasket);
    Workbasket updatedWorkbasket = workbasketService.getWorkbasket("GPK_KSC", "DOMAIN_A");
    Assert.assertEquals(workbasket.getId(), updatedWorkbasket.getId());
    Assert.assertEquals(workbasket.getCreated(), updatedWorkbasket.getCreated());
    Assert.assertNotEquals(modified, updatedWorkbasket.getModified());
    Assert.assertEquals("new name", updatedWorkbasket.getName());
    Assert.assertEquals(WorkbasketType.TOPIC, updatedWorkbasket.getType());
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) Instant(java.time.Instant) Workbasket(pro.taskana.Workbasket) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 20 with Workbasket

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

the class UpdateWorkbasketAccTest method testCheckAuthorizationToUpdateWorkbasket.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test(expected = NotAuthorizedException.class)
public void testCheckAuthorizationToUpdateWorkbasket() throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, InvalidWorkbasketException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    Workbasket workbasket = workbasketService.getWorkbasket("USER_1_1", "DOMAIN_A");
    workbasket.setName("new name");
    workbasketService.updateWorkbasket(workbasket);
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) Workbasket(pro.taskana.Workbasket) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Aggregations

Workbasket (pro.taskana.Workbasket)62 Test (org.junit.Test)47 WithAccessId (pro.taskana.security.WithAccessId)23 AbstractAccTest (acceptance.AbstractAccTest)18 Task (pro.taskana.Task)18 Classification (pro.taskana.Classification)17 WorkbasketService (pro.taskana.WorkbasketService)13 ArrayList (java.util.ArrayList)11 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)10 WorkbasketSummary (pro.taskana.WorkbasketSummary)9 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)9 WorkbasketNotFoundException (pro.taskana.exceptions.WorkbasketNotFoundException)9 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)7 Attachment (pro.taskana.Attachment)6 InvalidWorkbasketException (pro.taskana.exceptions.InvalidWorkbasketException)6 Instant (java.time.Instant)5 Transactional (org.springframework.transaction.annotation.Transactional)5 WorkbasketResource (pro.taskana.rest.resource.WorkbasketResource)5 Connection (java.sql.Connection)4