Search in sources :

Example 16 with WorkbasketAccessItem

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

the class WorkbasketServiceImplIntExplicitTest method createWorkbasketWithSecurity.

private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen, boolean permRead, boolean permAppend, boolean permTransfer) throws InvalidArgumentException, NotAuthorizedException {
    WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(wb.getId(), accessId);
    accessItem.setPermOpen(permOpen);
    accessItem.setPermRead(permRead);
    accessItem.setPermAppend(permAppend);
    accessItem.setPermTransfer(permTransfer);
    workBasketService.createWorkbasketAccessItem(accessItem);
}
Also used : WorkbasketAccessItem(pro.taskana.WorkbasketAccessItem)

Example 17 with WorkbasketAccessItem

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

the class WorkbasketServiceImplIntExplicitTest method testUpdateWorkbasketAccessUser.

@WithAccessId(userName = "Elena", groupNames = { "businessadmin" })
@Test
public void testUpdateWorkbasketAccessUser() throws NotAuthorizedException, SQLException, InvalidArgumentException {
    Connection connection = dataSource.getConnection();
    taskanaEngineImpl.setConnection(connection);
    workBasketService = taskanaEngine.getWorkbasketService();
    WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem("key2", "Zaphod Beeblebrox");
    accessItem.setPermOpen(true);
    accessItem.setPermRead(true);
    workBasketService.createWorkbasketAccessItem(accessItem);
    Assert.assertEquals(1, workBasketService.getWorkbasketAccessItems("key2").size());
    Assert.assertEquals("zaphod beeblebrox", accessItem.getAccessId());
    connection.commit();
}
Also used : WorkbasketAccessItem(pro.taskana.WorkbasketAccessItem) Connection(java.sql.Connection) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 18 with WorkbasketAccessItem

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

the class WorkbasketServiceImplIntAutocommitTest method testUpdateWorkbasketAccessUser.

@WithAccessId(userName = "Elena", groupNames = { "businessadmin" })
@Test
public void testUpdateWorkbasketAccessUser() throws NotAuthorizedException, InvalidArgumentException {
    WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem("k200000000000000000000000000000000000000", "Zaphod Beeblebrox");
    accessItem.setPermOpen(true);
    accessItem.setPermRead(true);
    workBasketService.createWorkbasketAccessItem(accessItem);
    Assert.assertEquals(1, workBasketService.getWorkbasketAccessItems("k200000000000000000000000000000000000000").size());
    accessItem.setPermAppend(true);
    workBasketService.updateWorkbasketAccessItem(accessItem);
    if (TaskanaEngineConfiguration.shouldUseLowerCaseForAccessIds()) {
        Assert.assertEquals("zaphod beeblebrox", accessItem.getAccessId());
    } else {
        Assert.assertEquals("Zaphod Beeblebrox", accessItem.getAccessId());
    }
}
Also used : WorkbasketAccessItem(pro.taskana.WorkbasketAccessItem) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 19 with WorkbasketAccessItem

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

the class UpdateWorkbasketAuthorizationsAccTest method testUpdateWorkbasketAccessItemSucceeds.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test
public void testUpdateWorkbasketAccessItemSucceeds() throws InvalidArgumentException, NotAuthorizedException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("key1000000000000000000000000000000000000", "user1");
    accessItem.setPermAppend(true);
    accessItem.setPermCustom11(true);
    accessItem.setPermRead(true);
    accessItem = workbasketService.createWorkbasketAccessItem(accessItem);
    accessItem.setPermCustom1(true);
    accessItem.setPermAppend(false);
    WorkbasketAccessItem updatedItem = workbasketService.updateWorkbasketAccessItem(accessItem);
    Assert.assertEquals(false, updatedItem.isPermAppend());
    Assert.assertEquals(true, updatedItem.isPermRead());
    Assert.assertEquals(true, updatedItem.isPermCustom11());
    Assert.assertEquals(true, updatedItem.isPermCustom1());
    Assert.assertEquals(false, updatedItem.isPermCustom2());
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) WorkbasketAccessItem(pro.taskana.WorkbasketAccessItem) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 20 with WorkbasketAccessItem

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

the class UpdateWorkbasketAuthorizationsAccTest method testInsertAccessItemList.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test
public void testInsertAccessItemList() 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();
    // insert new entry
    WorkbasketAccessItem newItem = workbasketService.newWorkbasketAccessItem(wbId, CurrentUserContext.getUserid());
    newItem.setPermRead(true);
    newItem.setPermOpen(true);
    newItem.setPermCustom12(true);
    accessItems.add(newItem);
    workbasketService.setWorkbasketAccessItems(wbId, accessItems);
    List<WorkbasketAccessItem> updatedAccessItems = workbasketService.getWorkbasketAccessItems(wbId);
    int countAfter = updatedAccessItems.size();
    assertTrue((countBefore + 1) == countAfter);
    item0 = updatedAccessItems.stream().filter(i -> i.getId().equals(updateId0)).findFirst().get();
    assertFalse(item0.isPermAppend());
    assertFalse(item0.isPermOpen());
    assertFalse(item0.isPermTransfer());
    assertFalse(item0.isPermAppend());
    assertFalse(item0.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)

Aggregations

WorkbasketAccessItem (pro.taskana.WorkbasketAccessItem)31 Test (org.junit.Test)18 WithAccessId (pro.taskana.security.WithAccessId)16 AbstractAccTest (acceptance.AbstractAccTest)11 WorkbasketService (pro.taskana.WorkbasketService)11 ArrayList (java.util.ArrayList)6 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)6 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)5 WorkbasketAccessItemResource (pro.taskana.rest.resource.WorkbasketAccessItemResource)5 Task (pro.taskana.Task)4 Connection (java.sql.Connection)3 KeyDomain (pro.taskana.KeyDomain)3 TaskService (pro.taskana.TaskService)3 TaskSummary (pro.taskana.TaskSummary)3 InvalidWorkbasketException (pro.taskana.exceptions.InvalidWorkbasketException)3 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)3 NotAuthorizedToQueryWorkbasketException (pro.taskana.exceptions.NotAuthorizedToQueryWorkbasketException)3 WorkbasketNotFoundException (pro.taskana.exceptions.WorkbasketNotFoundException)3 WorkbasketAccessItemImpl (pro.taskana.impl.WorkbasketAccessItemImpl)3 SQLException (java.sql.SQLException)2