From 6f4a83763cacc9a8266f0ffe0e515f8e91dd55a3 Mon Sep 17 00:00:00 2001
From: Daniel <d.hornung@indiscale.com>
Date: Wed, 9 Apr 2025 10:26:34 +0200
Subject: [PATCH] REFACTOR: Running tests as normal user

---
 .docker/Dockerfile    | 7 ++++++-
 tests/test_tickets.py | 1 -
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/.docker/Dockerfile b/.docker/Dockerfile
index 975eae8..9c03b2d 100644
--- a/.docker/Dockerfile
+++ b/.docker/Dockerfile
@@ -24,6 +24,7 @@ RUN rm -r /git/.git
 # Install pylinkahead.ini for the tests
 RUN mv /git/.docker/tester_pylinkahead.ini /git/pylinkahead.ini
 
+RUN useradd user
 
 WORKDIR /git
 # wait for server,
@@ -34,5 +35,9 @@ CMD /wait-for-it.sh caosdb-server:10443 -t 500 -- \
     # ... put out general version information
     python3 --version && \
     python3 -c "import linkahead; print(linkahead.version.version)" && \
+    chown -R user /authtoken && \
+    mkdir -p /extroot && \
+    chown -R user /extroot && \
+    chown -R user /git && \
     # ... and run tests
-    pytest --cov=linkahead -vv tests
+    su user -c "pytest --cov=linkahead -vv tests"
diff --git a/tests/test_tickets.py b/tests/test_tickets.py
index e9481d5..c535ed7 100644
--- a/tests/test_tickets.py
+++ b/tests/test_tickets.py
@@ -471,7 +471,6 @@ def test_ticket_137():
 
 
 # Test remodeled after removal of dropoffbox.
-@pytest.mark.xfail(reason="Fails if running as root.")
 def test_ticket_39(tmp_path):
     """Testing file upload of unreadable files."""
     import os
-- 
GitLab