Search in sources :

Example 86 with WithAccessId

use of pro.taskana.security.WithAccessId in project taskana by Taskana.

the class GetWorkbasketAccTest method testGetWorkbasketPermissions.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testGetWorkbasketPermissions() {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    List<WorkbasketPermission> permissions = workbasketService.getPermissionsForWorkbasket("WBI:100000000000000000000000000000000007");
    Assert.assertEquals(4, permissions.size());
    Assert.assertTrue(permissions.contains(WorkbasketPermission.READ));
    Assert.assertTrue(permissions.contains(WorkbasketPermission.OPEN));
    Assert.assertTrue(permissions.contains(WorkbasketPermission.TRANSFER));
    Assert.assertTrue(permissions.contains(WorkbasketPermission.APPEND));
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) WorkbasketPermission(pro.taskana.WorkbasketPermission) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 87 with WithAccessId

use of pro.taskana.security.WithAccessId in project taskana by Taskana.

the class DistributionTargetsAccTest method testQueryDistributionSourcesThrowsNotAuthorized.

@WithAccessId(userName = "henry", groupNames = { "undefinedgroup" })
@Test(expected = NotAuthorizedException.class)
public void testQueryDistributionSourcesThrowsNotAuthorized() throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException, SQLException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    List<WorkbasketSummary> distributionSources = workbasketService.getDistributionSources("WBI:100000000000000000000000000000000004");
    assertEquals(2, distributionSources.size());
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) WorkbasketSummary(pro.taskana.WorkbasketSummary) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 88 with WithAccessId

use of pro.taskana.security.WithAccessId in project taskana by Taskana.

the class DistributionTargetsAccTest method testGetDistributionSourcesById.

@WithAccessId(userName = "user_2_2", groupNames = { "group_1", "group_2" })
@Test
public void testGetDistributionSourcesById() throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException, SQLException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    List<WorkbasketSummary> distributionSources = workbasketService.getDistributionSources("WBI:100000000000000000000000000000000004");
    assertEquals(2, distributionSources.size());
    List<String> expectedIds = new ArrayList<>(Arrays.asList("WBI:100000000000000000000000000000000001", "WBI:100000000000000000000000000000000002"));
    for (WorkbasketSummary foundSummary : distributionSources) {
        assertTrue(expectedIds.contains(foundSummary.getId()));
    }
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) ArrayList(java.util.ArrayList) WorkbasketSummary(pro.taskana.WorkbasketSummary) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 89 with WithAccessId

use of pro.taskana.security.WithAccessId in project taskana by Taskana.

the class DistributionTargetsAccTest method testDistributionTargetCallsWithNonExistingWorkbaskets.

@WithAccessId(userName = "user_1_1", groupNames = { "teamlead_1", "group_1", "group_2", "businessadmin" })
@Test
public void testDistributionTargetCallsWithNonExistingWorkbaskets() throws NotAuthorizedException, WorkbasketNotFoundException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    String existingWb = "WBI:100000000000000000000000000000000001";
    String nonExistingWb = "WBI:100000000000000000000000000000000xx1";
    try {
        workbasketService.getDistributionTargets("WBI:100000000000000000000000000000000xx1");
        assertTrue("This line of code should not be reached", false);
    } catch (WorkbasketNotFoundException ex) {
    // nothing to do
    }
    try {
        List<String> distributionTargets = new ArrayList<>(Arrays.asList(nonExistingWb));
        workbasketService.setDistributionTargets(existingWb, distributionTargets);
        assertTrue("This line of code should not be reached", false);
    } catch (WorkbasketNotFoundException ex) {
    // nothing to do
    }
    try {
        workbasketService.addDistributionTarget(existingWb, nonExistingWb);
        assertTrue("This line of code should not be reached", false);
    } catch (WorkbasketNotFoundException ex) {
    // nothing to do
    }
    int beforeCount = workbasketService.getDistributionTargets(existingWb).size();
    workbasketService.removeDistributionTarget(existingWb, nonExistingWb);
    int afterCount = workbasketService.getDistributionTargets(existingWb).size();
    assertEquals(afterCount, beforeCount);
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) ArrayList(java.util.ArrayList) WorkbasketNotFoundException(pro.taskana.exceptions.WorkbasketNotFoundException) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 90 with WithAccessId

use of pro.taskana.security.WithAccessId 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)

Aggregations

Test (org.junit.Test)216 WithAccessId (pro.taskana.security.WithAccessId)216 AbstractAccTest (acceptance.AbstractAccTest)201 TaskService (pro.taskana.TaskService)100 WorkbasketService (pro.taskana.WorkbasketService)78 Task (pro.taskana.Task)57 WorkbasketSummary (pro.taskana.WorkbasketSummary)51 TaskSummary (pro.taskana.TaskSummary)47 TaskanaEngineProxyForTest (pro.taskana.impl.TaskanaEngineProxyForTest)34 Workbasket (pro.taskana.Workbasket)23 Classification (pro.taskana.Classification)21 KeyDomain (pro.taskana.KeyDomain)19 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)19 ArrayList (java.util.ArrayList)17 Instant (java.time.Instant)16 WorkbasketAccessItem (pro.taskana.WorkbasketAccessItem)16 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)15 Connection (java.sql.Connection)10 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)9 TimeInterval (pro.taskana.TimeInterval)8