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