use of pro.taskana.configuration.TaskanaEngineConfiguration in project taskana by Taskana.
the class TaskServiceImplIntExplicitTest method shouldNotTransferByFailingSecurity.
@WithAccessId(userName = "User", groupNames = { "businessadmin" })
@Test
public void shouldNotTransferByFailingSecurity() throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, SQLException, TaskNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
final String user = "User";
// Set up Security for this Test
dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, true);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
taskanaEngineImpl.setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
taskServiceImpl = (TaskServiceImpl) taskanaEngine.getTaskService();
classificationService = taskanaEngine.getClassificationService();
workbasketService = taskanaEngine.getWorkbasketService();
ClassificationImpl classification = (ClassificationImpl) classificationService.newClassification("KEY", "DOMAIN_A", "TASK");
classification.setCategory("EXTERNAL");
classification.setName("Transfert-Task Classification");
classificationService.createClassification(classification);
WorkbasketImpl wb = (WorkbasketImpl) workbasketService.newWorkbasket("wbKey1", "DOMAIN_A");
wb.setName("BASE WB");
wb.setDescription("Normal base WB");
wb.setOwner(user);
wb.setType(WorkbasketType.GROUP);
wb = (WorkbasketImpl) workbasketService.createWorkbasket(wb);
createWorkbasketWithSecurity(wb, wb.getOwner(), true, true, true, true);
WorkbasketImpl wbNoAppend = (WorkbasketImpl) workbasketService.newWorkbasket("keyNoAppend", "DOMAIN_B");
wbNoAppend.setName("Test-Security-WorkBasket-APPEND");
wbNoAppend.setDescription("Workbasket without permission APPEND on Task");
wbNoAppend.setOwner(user);
wbNoAppend.setType(WorkbasketType.CLEARANCE);
wbNoAppend = (WorkbasketImpl) workbasketService.createWorkbasket(wbNoAppend);
createWorkbasketWithSecurity(wbNoAppend, wbNoAppend.getOwner(), true, true, false, true);
WorkbasketImpl wbNoTransfer = (WorkbasketImpl) workbasketService.newWorkbasket("keyNoTransfer", "DOMAIN_A");
wbNoTransfer.setName("Test-Security-WorkBasket-TRANSFER");
wbNoTransfer.setDescription("Workbasket without permission TRANSFER on Task");
wbNoTransfer.setOwner(user);
wbNoTransfer.setType(WorkbasketType.GROUP);
wbNoTransfer = (WorkbasketImpl) workbasketService.createWorkbasket(wbNoTransfer);
createWorkbasketWithSecurity(wbNoTransfer, wbNoTransfer.getOwner(), true, true, true, false);
TaskImpl task = (TaskImpl) taskServiceImpl.newTask(wb.getId());
task.setName("Task Name");
task.setDescription("Task used for transfer Test");
task.setOwner(user);
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task = (TaskImpl) taskServiceImpl.createTask(task);
// Check failing with missing APPEND
try {
task = (TaskImpl) taskServiceImpl.transfer(task.getId(), wbNoAppend.getId());
fail("Transfer Task should be FAILD, because there are no APPEND-Rights on destination WB.");
} catch (NotAuthorizedException e) {
if (!e.getMessage().contains("APPEND")) {
fail("Transfer Task should be FAILD, because there are no APPEND-Rights on destination WB.");
}
assertThat(task.isTransferred(), equalTo(false));
assertThat(task.getWorkbasketKey(), not(equalTo(wbNoAppend.getKey())));
assertThat(task.getWorkbasketKey(), equalTo(wb.getKey()));
}
// Check failing with missing TRANSFER
task.setId("");
task.setWorkbasketKey(wbNoTransfer.getKey());
task.getWorkbasketSummaryImpl().setId(wbNoTransfer.getId());
task = (TaskImpl) taskServiceImpl.createTask(task);
try {
task = (TaskImpl) taskServiceImpl.transfer(task.getId(), wb.getId());
fail("Transfer Task should be FAILD, because there are no TRANSFER-Rights on current WB.");
} catch (NotAuthorizedException e) {
if (!e.getMessage().contains("TRANSFER")) {
fail("Transfer Task should be FAILD, because there are no APPEND-Rights on current WB.");
}
assertThat(task.isTransferred(), equalTo(false));
assertThat(task.getWorkbasketKey(), not(equalTo(wbNoAppend.getKey())));
}
}
use of pro.taskana.configuration.TaskanaEngineConfiguration in project taskana by Taskana.
the class TaskServiceImplIntExplicitTest method testCreateTaskInTaskanaWithDefaultDb.
@WithAccessId(userName = "Elena", groupNames = { "businessadmin" })
@Test
public void testCreateTaskInTaskanaWithDefaultDb() throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
DataSource ds = TaskanaEngineConfiguration.createDefaultDataSource();
DBCleaner cleaner = new DBCleaner();
cleaner.clearDb(ds, false);
TaskanaEngineConfiguration taskanaEngineConfiguration = new TaskanaEngineConfiguration(ds, false, false);
TaskanaEngine te = taskanaEngineConfiguration.buildTaskanaEngine();
Connection connection = ds.getConnection();
te.setConnection(connection);
TaskServiceImpl taskServiceImpl = (TaskServiceImpl) te.getTaskService();
WorkbasketServiceImpl workBasketServiceImpl = (WorkbasketServiceImpl) te.getWorkbasketService();
ClassificationServiceImpl classificationServiceImpl = (ClassificationServiceImpl) te.getClassificationService();
Workbasket workbasket = workbasketService.newWorkbasket("K99", "DOMAIN_A");
workbasket.setName("workbasket");
workbasket.setName("workbasket99");
workbasket.setType(WorkbasketType.GROUP);
workbasket = workBasketServiceImpl.createWorkbasket(workbasket);
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
classification = classificationServiceImpl.createClassification(classification);
Task task = taskServiceImpl.newTask(workbasket.getId());
task.setName("Unit Test Task");
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task.addAttachment(null);
task = taskServiceImpl.createTask(task);
Assert.assertNotNull(task);
Assert.assertNotNull(task.getId());
connection.commit();
te.setConnection(null);
}
use of pro.taskana.configuration.TaskanaEngineConfiguration in project taskana by Taskana.
the class TaskServiceImplIntAutocommitTest method testCreateTaskInTaskanaWithDefaultDb.
@Test
public void testCreateTaskInTaskanaWithDefaultDb() throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
DBCleaner cleaner = new DBCleaner();
cleaner.clearDb(TaskanaEngineConfiguration.createDefaultDataSource(), false);
TaskanaEngineConfiguration taskanaEngineConfiguration = new TaskanaEngineConfiguration(null, false, false);
TaskanaEngine te = taskanaEngineConfiguration.buildTaskanaEngine();
((TaskanaEngineImpl) te).setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
TaskServiceImpl taskServiceImpl = (TaskServiceImpl) te.getTaskService();
Workbasket wb = workbasketService.newWorkbasket("workbasket", "DOMAIN_A");
wb.setName("workbasket");
wb.setType(WorkbasketType.GROUP);
te.getWorkbasketService().createWorkbasket(wb);
Classification classification = te.getClassificationService().newClassification("TEST", "DOMAIN_A", "TASK");
te.getClassificationService().createClassification(classification);
Task task = taskServiceImpl.newTask(wb.getId());
task.setName("Unit Test Task");
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task = taskServiceImpl.createTask(task);
Assert.assertNotNull(task);
Assert.assertNotNull(task.getId());
}
use of pro.taskana.configuration.TaskanaEngineConfiguration in project taskana by Taskana.
the class TaskanaProducers method init.
@PostConstruct
public void init() {
// Load Properties and get Datasource via Context
// Load DataSource via Container
Context ctx;
DataSource dataSource;
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
try (InputStream propertyStream = classloader.getResourceAsStream(TASKANA_PROPERTIES)) {
Properties properties = new Properties();
ctx = new InitialContext();
properties.load(propertyStream);
dataSource = (DataSource) ctx.lookup(properties.getProperty("datasource.jndi"));
logger.debug("---------------> " + dataSource.getConnection().getMetaData());
this.taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, true, false);
} catch (NamingException | SQLException | IOException e) {
logger.error("Could not start Taskana: ", e);
}
}
use of pro.taskana.configuration.TaskanaEngineConfiguration in project taskana by Taskana.
the class ProvideTaskStatusReportAccTest method resetDb.
public static void resetDb() throws SQLException, IOException {
DataSource dataSource = TaskanaEngineConfigurationTest.getDataSource();
DBCleaner cleaner = new DBCleaner();
cleaner.clearDb(dataSource, true);
dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false);
taskanaEngineConfiguration.setGermanPublicHolidaysEnabled(false);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
taskanaEngine.setConnectionManagementMode(TaskanaEngine.ConnectionManagementMode.AUTOCOMMIT);
cleaner.clearDb(dataSource, false);
TestDataGenerator testDataGenerator = new TestDataGenerator();
testDataGenerator.generateMonitoringTestData(dataSource);
}
Aggregations