From d987a7e7cb19367d708e21f9ef881afecffe35a3 Mon Sep 17 00:00:00 2001
From: Hannah von Reth <hannah.vonreth@owncloud.com>
Date: Wed, 29 Sep 2021 13:36:26 +0200
Subject: [PATCH] Fix unit test for the root user

---
 test/testdownload.cpp  | 4 ++++
 test/testfolderman.cpp | 8 +++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/test/testdownload.cpp b/test/testdownload.cpp
index b37cb807da..4af30ae72e 100644
--- a/test/testdownload.cpp
+++ b/test/testdownload.cpp
@@ -150,6 +150,10 @@ private slots:
     void testMoveFailsInAConflict() {
 #ifdef Q_OS_WIN
         QSKIP("Not run on windows because permission on directory does not do what is expected");
+#else
+        if (getuid() == 0) {
+            QSKIP("The permissions have no effect on the root user");
+        }
 #endif
         // Test for https://github.com/owncloud/client/issues/7015
         // We want to test the case in which the renaming of the original to the conflict file succeeds,
diff --git a/test/testfolderman.cpp b/test/testfolderman.cpp
index 8fc2cc2627..47213ed6b9 100644
--- a/test/testfolderman.cpp
+++ b/test/testfolderman.cpp
@@ -102,9 +102,11 @@ private slots:
         QVERIFY(folderman->checkPathValidityForNewFolder(dirPath + "/link1/subfolder").isNull());
         QVERIFY(folderman->checkPathValidityForNewFolder(dirPath + "/link2/free/subfolder").isNull());
 
-        // Should not have the rights
-        QVERIFY(!folderman->checkPathValidityForNewFolder("/").isNull());
-        QVERIFY(!folderman->checkPathValidityForNewFolder("/usr/bin/somefolder").isNull());
+        if (getuid() != 0) {
+            // Should not have the rights
+            QVERIFY(!folderman->checkPathValidityForNewFolder("/").isNull());
+            QVERIFY(!folderman->checkPathValidityForNewFolder("/usr/bin/somefolder").isNull());
+        }
 #endif
 
 #ifdef Q_OS_WIN // drive-letter tests
