parent
b86f3e5b65
commit
7477092a69
|
|
@ -31,6 +31,17 @@ public class AbstractAccTest {
|
||||||
private static DataSource dataSource;
|
private static DataSource dataSource;
|
||||||
private static String schemaName = null;
|
private static String schemaName = null;
|
||||||
|
|
||||||
|
static {
|
||||||
|
String userHomeDirectroy = System.getProperty("user.home");
|
||||||
|
String propertiesFileName = userHomeDirectroy + "/taskanaUnitTest.properties";
|
||||||
|
File f = new File(propertiesFileName);
|
||||||
|
if (f.exists() && !f.isDirectory()) {
|
||||||
|
dataSource = createDataSourceFromProperties(propertiesFileName);
|
||||||
|
} else {
|
||||||
|
dataSource = createDefaultDataSource();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected AbstractAccTest() {
|
protected AbstractAccTest() {
|
||||||
// not called
|
// not called
|
||||||
}
|
}
|
||||||
|
|
@ -56,17 +67,6 @@ public class AbstractAccTest {
|
||||||
writer.generateTestData(dataSource);
|
writer.generateTestData(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
|
||||||
String userHomeDirectroy = System.getProperty("user.home");
|
|
||||||
String propertiesFileName = userHomeDirectroy + "/taskanaUnitTest.properties";
|
|
||||||
File f = new File(propertiesFileName);
|
|
||||||
if (f.exists() && !f.isDirectory()) {
|
|
||||||
dataSource = createDataSourceFromProperties(propertiesFileName);
|
|
||||||
} else {
|
|
||||||
dataSource = createDefaultDataSource();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DataSource getDataSource() {
|
public static DataSource getDataSource() {
|
||||||
if (dataSource == null) {
|
if (dataSource == null) {
|
||||||
throw new RuntimeException("Datasource should be already initialized");
|
throw new RuntimeException("Datasource should be already initialized");
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,10 @@ public class TaskanaEngineConfigurationTest extends AbstractAccTest {
|
||||||
resetDb("SOMECUSTOMSCHEMANAME");
|
resetDb("SOMECUSTOMSCHEMANAME");
|
||||||
long count = getHistoryService().createHistoryQuery().workbasketKeyIn("wbKey1").count();
|
long count = getHistoryService().createHistoryQuery().workbasketKeyIn("wbKey1").count();
|
||||||
assertEquals(0, count);
|
assertEquals(0, count);
|
||||||
getHistoryService().create(
|
getHistoryService()
|
||||||
AbstractAccTest.createHistoryEvent("wbKey1", "taskId1", "type1", "Some comment", "wbKey2"));
|
.create(
|
||||||
|
AbstractAccTest.createHistoryEvent(
|
||||||
|
"wbKey1", "taskId1", "type1", "Some comment", "wbKey2"));
|
||||||
count = getHistoryService().createHistoryQuery().workbasketKeyIn("wbKey1").count();
|
count = getHistoryService().createHistoryQuery().workbasketKeyIn("wbKey1").count();
|
||||||
assertEquals(1, count);
|
assertEquals(1, count);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,6 @@ public interface InternalTaskanaEngine {
|
||||||
*/
|
*/
|
||||||
TaskRoutingManager getTaskRoutingManager();
|
TaskRoutingManager getTaskRoutingManager();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is supposed to skip further permission checks if we are already in a secured
|
* This method is supposed to skip further permission checks if we are already in a secured
|
||||||
* environment. With great power comes great responsibility.
|
* environment. With great power comes great responsibility.
|
||||||
|
|
|
||||||
|
|
@ -332,31 +332,6 @@ public class TaskanaEngineImpl implements TaskanaEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> T runAsAdmin(Supplier<T> supplier) {
|
|
||||||
|
|
||||||
Subject subject = Subject.getSubject(AccessController.getContext());
|
|
||||||
if (subject == null) {
|
|
||||||
// dont add authorisation if none is available.
|
|
||||||
return supplier.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
Set<Principal> principalsCopy = new HashSet<>(subject.getPrincipals());
|
|
||||||
Set<Object> privateCredentialsCopy = new HashSet<>(subject.getPrivateCredentials());
|
|
||||||
Set<Object> publicCredentialsCopy = new HashSet<>(subject.getPublicCredentials());
|
|
||||||
|
|
||||||
String adminName =
|
|
||||||
this.getEngine().getConfiguration().getRoleMap().get(TaskanaRole.ADMIN).stream()
|
|
||||||
.findFirst()
|
|
||||||
.orElseThrow(() -> new TaskanaRuntimeException("There is no admin configured"));
|
|
||||||
|
|
||||||
principalsCopy.add(new GroupPrincipal(adminName));
|
|
||||||
Subject subject1 =
|
|
||||||
new Subject(true, principalsCopy, privateCredentialsCopy, publicCredentialsCopy);
|
|
||||||
|
|
||||||
return Subject.doAs(subject1, (PrivilegedAction<T>) supplier::get);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void returnConnection() {
|
public void returnConnection() {
|
||||||
if (mode != ConnectionManagementMode.EXPLICIT) {
|
if (mode != ConnectionManagementMode.EXPLICIT) {
|
||||||
|
|
@ -421,5 +396,30 @@ public class TaskanaEngineImpl implements TaskanaEngine {
|
||||||
public TaskRoutingManager getTaskRoutingManager() {
|
public TaskRoutingManager getTaskRoutingManager() {
|
||||||
return taskRoutingManager;
|
return taskRoutingManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T runAsAdmin(Supplier<T> supplier) {
|
||||||
|
|
||||||
|
Subject subject = Subject.getSubject(AccessController.getContext());
|
||||||
|
if (subject == null) {
|
||||||
|
// dont add authorisation if none is available.
|
||||||
|
return supplier.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<Principal> principalsCopy = new HashSet<>(subject.getPrincipals());
|
||||||
|
Set<Object> privateCredentialsCopy = new HashSet<>(subject.getPrivateCredentials());
|
||||||
|
Set<Object> publicCredentialsCopy = new HashSet<>(subject.getPublicCredentials());
|
||||||
|
|
||||||
|
String adminName =
|
||||||
|
this.getEngine().getConfiguration().getRoleMap().get(TaskanaRole.ADMIN).stream()
|
||||||
|
.findFirst()
|
||||||
|
.orElseThrow(() -> new TaskanaRuntimeException("There is no admin configured"));
|
||||||
|
|
||||||
|
principalsCopy.add(new GroupPrincipal(adminName));
|
||||||
|
Subject subject1 =
|
||||||
|
new Subject(true, principalsCopy, privateCredentialsCopy, publicCredentialsCopy);
|
||||||
|
|
||||||
|
return Subject.doAs(subject1, (PrivilegedAction<T>) supplier::get);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,24 +108,6 @@ public class ScheduledJob {
|
||||||
this.retryCount = retryCount;
|
this.retryCount = retryCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This enum tracks the state of a job.
|
|
||||||
*
|
|
||||||
* @author bbr
|
|
||||||
*/
|
|
||||||
public enum State {
|
|
||||||
READY,
|
|
||||||
FAILED
|
|
||||||
}
|
|
||||||
|
|
||||||
/** This enum controls the type of a job. */
|
|
||||||
public enum Type {
|
|
||||||
CLASSIFICATIONCHANGEDJOB,
|
|
||||||
UPDATETASKSJOB,
|
|
||||||
TASKCLEANUPJOB,
|
|
||||||
WORKBASKETCLEANUPJOB;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(
|
return Objects.hash(
|
||||||
|
|
@ -177,4 +159,22 @@ public class ScheduledJob {
|
||||||
+ arguments
|
+ arguments
|
||||||
+ "]";
|
+ "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This enum tracks the state of a job.
|
||||||
|
*
|
||||||
|
* @author bbr
|
||||||
|
*/
|
||||||
|
public enum State {
|
||||||
|
READY,
|
||||||
|
FAILED
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This enum controls the type of a job. */
|
||||||
|
public enum Type {
|
||||||
|
CLASSIFICATIONCHANGEDJOB,
|
||||||
|
UPDATETASKSJOB,
|
||||||
|
TASKCLEANUPJOB,
|
||||||
|
WORKBASKETCLEANUPJOB;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,7 @@ public interface JobMapper {
|
||||||
+ "</choose>"
|
+ "</choose>"
|
||||||
+ ", #{job.priority}, #{job.created}, #{job.due}, #{job.state}, #{job.lockedBy}, #{job.lockExpires}, #{job.type}, #{job.retryCount}, #{job.arguments,javaType=java.util.Map,typeHandler=pro.taskana.impl.persistence.MapTypeHandler} )"
|
+ ", #{job.priority}, #{job.created}, #{job.due}, #{job.state}, #{job.lockedBy}, #{job.lockExpires}, #{job.type}, #{job.retryCount}, #{job.arguments,javaType=java.util.Map,typeHandler=pro.taskana.impl.persistence.MapTypeHandler} )"
|
||||||
+ "</script>")
|
+ "</script>")
|
||||||
@Results(
|
@Results(value = {@Result(property = "jobId", column = "JOB_ID")})
|
||||||
value = {
|
|
||||||
@Result(property = "jobId", column = "JOB_ID")})
|
|
||||||
Integer insertJob(@Param("job") ScheduledJob job);
|
Integer insertJob(@Param("job") ScheduledJob job);
|
||||||
|
|
||||||
@Select(
|
@Select(
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,6 @@ public final class TaskanaEngineTestConfiguration {
|
||||||
private static DataSource dataSource;
|
private static DataSource dataSource;
|
||||||
private static String schemaName = null;
|
private static String schemaName = null;
|
||||||
|
|
||||||
private TaskanaEngineTestConfiguration() {}
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
String userHomeDirectroy = System.getProperty("user.home");
|
String userHomeDirectroy = System.getProperty("user.home");
|
||||||
String propertiesFileName = userHomeDirectroy + "/taskanaUnitTest.properties";
|
String propertiesFileName = userHomeDirectroy + "/taskanaUnitTest.properties";
|
||||||
|
|
@ -37,6 +35,8 @@ public final class TaskanaEngineTestConfiguration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TaskanaEngineTestConfiguration() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the Datasource used for Junit test. If the file {user.home}/taskanaUnitTest.properties
|
* returns the Datasource used for Junit test. If the file {user.home}/taskanaUnitTest.properties
|
||||||
* is present, the Datasource is created according to the properties jdbcDriver, jdbcUrl,
|
* is present, the Datasource is created according to the properties jdbcDriver, jdbcUrl,
|
||||||
|
|
|
||||||
|
|
@ -109,9 +109,8 @@ class WorkbasketControllerIntTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bug Ticket TSK-1029.
|
* Bug Ticket TSK-1029. Businessadmin is allowed to delete any workbasket ticket without user
|
||||||
* Businessadmin is allowed to delete any workbasket ticket without user related access
|
* related access restrictions.
|
||||||
* restrictions.
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void testDeleteWorkbasketAsBusinessAdminWithoutExplicitReadPermission() {
|
void testDeleteWorkbasketAsBusinessAdminWithoutExplicitReadPermission() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue