Skip to content

Commit

Permalink
Merge pull request kitodo#6022 from slub/fix_permission_denied_error_…
Browse files Browse the repository at this point in the history
…messages

Fix permission denied messages while running tests
  • Loading branch information
solth authored Apr 10, 2024
2 parents 5e5a86e + 127d2ef commit b416e9c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;

import java.io.File;
import java.util.List;
import java.util.Objects;

Expand All @@ -25,8 +26,11 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.kitodo.ExecutionPermission;
import org.kitodo.MockDatabase;
import org.kitodo.SecurityTestUtils;
import org.kitodo.config.ConfigCore;
import org.kitodo.config.enums.ParameterCore;
import org.kitodo.data.database.beans.Comment;
import org.kitodo.data.database.beans.Task;
import org.kitodo.data.database.enums.TaskStatus;
Expand All @@ -38,6 +42,11 @@ public class TaskActionProcessorIT {

private static final TaskService taskService = ServiceManager.getTaskService();

private static final File scriptDeleteSymLink = new File(
ConfigCore.getParameter(ParameterCore.SCRIPT_DELETE_SYMLINK));
private static final File scriptCreateDirMeta = new File(
ConfigCore.getParameter(ParameterCore.SCRIPT_CREATE_DIR_USER_HOME));

/**
* Prepare the data for every test.
*
Expand All @@ -49,6 +58,8 @@ public void prepare() throws Exception {
MockDatabase.startNode();
MockDatabase.insertProcessesForWorkflowFull();
SecurityTestUtils.addUserDataToSecurityContext(ServiceManager.getUserService().getById(1), 1);
ExecutionPermission.setExecutePermission(scriptCreateDirMeta);
ExecutionPermission.setExecutePermission(scriptDeleteSymLink);
}

/**
Expand All @@ -62,6 +73,8 @@ public void clean() throws Exception {
MockDatabase.stopNode();
MockDatabase.cleanDatabase();
SecurityTestUtils.cleanSecurityContext();
ExecutionPermission.setNoExecutePermission(scriptCreateDirMeta);
ExecutionPermission.setNoExecutePermission(scriptDeleteSymLink);
}

@Test(expected = ProcessorException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public class WorkflowControllerServiceIT {
ConfigCore.getParameter(ParameterCore.SCRIPT_CREATE_DIR_USER_HOME));
private static final File scriptCreateSymLink = new File(
ConfigCore.getParameter(ParameterCore.SCRIPT_CREATE_SYMLINK));
private static final File scriptDeleteSymLink = new File(
ConfigCore.getParameter(ParameterCore.SCRIPT_DELETE_SYMLINK));
private static final File scriptNotWorking = new File("src/test/resources/scripts/not_working_script.sh");
private static final File scriptWorking = new File("src/test/resources/scripts/working_script.sh");
private static final File usersDirectory = new File("src/test/resources/users");
Expand All @@ -79,6 +81,7 @@ public void prepareDatabase() throws Exception {
if (!SystemUtils.IS_OS_WINDOWS) {
ExecutionPermission.setExecutePermission(scriptCreateDirUserHome);
ExecutionPermission.setExecutePermission(scriptCreateSymLink);
ExecutionPermission.setExecutePermission(scriptDeleteSymLink);
ExecutionPermission.setExecutePermission(scriptNotWorking);
ExecutionPermission.setExecutePermission(scriptWorking);
}
Expand All @@ -95,6 +98,7 @@ public void cleanDatabase() throws Exception {
if (!SystemUtils.IS_OS_WINDOWS) {
ExecutionPermission.setNoExecutePermission(scriptCreateDirUserHome);
ExecutionPermission.setNoExecutePermission(scriptCreateSymLink);
ExecutionPermission.setNoExecutePermission(scriptDeleteSymLink);
ExecutionPermission.setNoExecutePermission(scriptNotWorking);
ExecutionPermission.setNoExecutePermission(scriptWorking);
}
Expand Down

0 comments on commit b416e9c

Please sign in to comment.