parent
b86f3e5b65
commit
7477092a69
|
@ -31,6 +31,17 @@ public class AbstractAccTest {
|
|||
private static DataSource dataSource;
|
||||
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() {
|
||||
// not called
|
||||
}
|
||||
|
@ -56,17 +67,6 @@ public class AbstractAccTest {
|
|||
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() {
|
||||
if (dataSource == null) {
|
||||
throw new RuntimeException("Datasource should be already initialized");
|
||||
|
|
|
@ -34,8 +34,10 @@ public class TaskanaEngineConfigurationTest extends AbstractAccTest {
|
|||
resetDb("SOMECUSTOMSCHEMANAME");
|
||||
long count = getHistoryService().createHistoryQuery().workbasketKeyIn("wbKey1").count();
|
||||
assertEquals(0, count);
|
||||
getHistoryService().create(
|
||||
AbstractAccTest.createHistoryEvent("wbKey1", "taskId1", "type1", "Some comment", "wbKey2"));
|
||||
getHistoryService()
|
||||
.create(
|
||||
AbstractAccTest.createHistoryEvent(
|
||||
"wbKey1", "taskId1", "type1", "Some comment", "wbKey2"));
|
||||
count = getHistoryService().createHistoryQuery().workbasketKeyIn("wbKey1").count();
|
||||
assertEquals(1, count);
|
||||
}
|
||||
|
|
|
@ -167,10 +167,10 @@ public class TaskHistoryEventControllerRestDocumentation {
|
|||
fieldWithPath("taskHistoryEvents[].newData")
|
||||
.description(taskHistoryEventFieldDescriptionsMap.get("newData")),
|
||||
fieldWithPath("_links.self.href").ignored(),
|
||||
fieldWithPath("page.size").ignored(),
|
||||
fieldWithPath("page.totalElements").ignored(),
|
||||
fieldWithPath("page.totalPages").ignored(),
|
||||
fieldWithPath("page.number").ignored()
|
||||
fieldWithPath("page.size").ignored(),
|
||||
fieldWithPath("page.totalElements").ignored(),
|
||||
fieldWithPath("page.totalPages").ignored(),
|
||||
fieldWithPath("page.number").ignored()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,6 @@ public interface InternalTaskanaEngine {
|
|||
*/
|
||||
TaskRoutingManager getTaskRoutingManager();
|
||||
|
||||
|
||||
/**
|
||||
* This method is supposed to skip further permission checks if we are already in a secured
|
||||
* 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
|
||||
public void returnConnection() {
|
||||
if (mode != ConnectionManagementMode.EXPLICIT) {
|
||||
|
@ -421,5 +396,30 @@ public class TaskanaEngineImpl implements TaskanaEngine {
|
|||
public TaskRoutingManager getTaskRoutingManager() {
|
||||
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 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
|
||||
public int hashCode() {
|
||||
return Objects.hash(
|
||||
|
@ -177,4 +159,22 @@ public class ScheduledJob {
|
|||
+ 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>"
|
||||
+ ", #{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>")
|
||||
@Results(
|
||||
value = {
|
||||
@Result(property = "jobId", column = "JOB_ID")})
|
||||
@Results(value = {@Result(property = "jobId", column = "JOB_ID")})
|
||||
Integer insertJob(@Param("job") ScheduledJob job);
|
||||
|
||||
@Select(
|
||||
|
|
|
@ -24,8 +24,6 @@ public final class TaskanaEngineTestConfiguration {
|
|||
private static DataSource dataSource;
|
||||
private static String schemaName = null;
|
||||
|
||||
private TaskanaEngineTestConfiguration() {}
|
||||
|
||||
static {
|
||||
String userHomeDirectroy = System.getProperty("user.home");
|
||||
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
|
||||
* is present, the Datasource is created according to the properties jdbcDriver, jdbcUrl,
|
||||
|
|
|
@ -113,7 +113,7 @@ public class TaskanaRestExceptionHandler extends ResponseEntityExceptionHandler
|
|||
WorkbasketAlreadyExistException ex, WebRequest req) {
|
||||
return buildResponse(ex, req, HttpStatus.CONFLICT);
|
||||
}
|
||||
|
||||
|
||||
@ExceptionHandler(WorkbasketAccessItemAlreadyExistException.class)
|
||||
protected ResponseEntity<Object> handleWorkbasketAccessItemAlreadyExist(
|
||||
WorkbasketAccessItemAlreadyExistException ex, WebRequest req) {
|
||||
|
|
|
@ -105,10 +105,10 @@ class WorkbasketAccessItemControllerRestDocumentation extends BaseRestDocumentat
|
|||
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom12")),
|
||||
fieldWithPath("_links.self.href")
|
||||
.description(accessItemFieldDescriptionsMap.get("_links.self.href")),
|
||||
fieldWithPath("page.size").ignored(),
|
||||
fieldWithPath("page.totalElements").ignored(),
|
||||
fieldWithPath("page.totalPages").ignored(),
|
||||
fieldWithPath("page.number").ignored()
|
||||
fieldWithPath("page.size").ignored(),
|
||||
fieldWithPath("page.totalElements").ignored(),
|
||||
fieldWithPath("page.totalPages").ignored(),
|
||||
fieldWithPath("page.number").ignored()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -109,9 +109,8 @@ class WorkbasketControllerIntTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* Bug Ticket TSK-1029.
|
||||
* Businessadmin is allowed to delete any workbasket ticket without user related access
|
||||
* restrictions.
|
||||
* Bug Ticket TSK-1029. Businessadmin is allowed to delete any workbasket ticket without user
|
||||
* related access restrictions.
|
||||
*/
|
||||
@Test
|
||||
void testDeleteWorkbasketAsBusinessAdminWithoutExplicitReadPermission() {
|
||||
|
|
Loading…
Reference in New Issue