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));
}
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());
}
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()));
}
}
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);
}
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");
}
Aggregations