]> source.dussan.org Git - nextcloud-server.git/commitdiff
tests: Fix test isolation on object storage
authorJulius Härtl <jus@bitgrid.net>
Thu, 9 Feb 2023 19:44:07 +0000 (20:44 +0100)
committerJulius Härtl <jus@bitgrid.net>
Fri, 17 Feb 2023 18:18:38 +0000 (19:18 +0100)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
apps/files_sharing/tests/ApiTest.php
apps/files_sharing/tests/TestCase.php

index d7661297e9e860de1d0d8f1f72d3a412de3fad34..d9b61f837eb5f051c3aec1b49d4580439284046c 100644 (file)
@@ -73,6 +73,7 @@ class ApiTest extends TestCase {
 
                \OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups', 'no');
                \OC::$server->getConfig()->setAppValue('core', 'shareapi_expire_after_n_days', '7');
+               \OC::$server->getConfig()->setAppValue('core', 'shareapi_enforce_links_password', 'no');
 
                $this->folder = self::TEST_FOLDER_NAME;
                $this->subfolder = '/subfolder_share_api_test';
@@ -80,6 +81,11 @@ class ApiTest extends TestCase {
 
                $this->filename = '/share-api-test.txt';
 
+               // Initialize view again as we delete all filecache/mount entries in tearDown
+               // Otherwise those tests fail on object storage as the filecache is missing the user home
+               $this->view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
+               $this->view2 = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
+
                // save file with content
                $this->view->file_put_contents($this->filename, $this->data);
                $this->view->mkdir($this->folder);
index 2bd83d6c9c28f5fe3e90ac0a0dc3c580e68d52a5..abdb6a2d60f39f4bee283c1eaa32321fa6de6ec3 100644 (file)
@@ -33,6 +33,7 @@
 namespace OCA\Files_Sharing\Tests;
 
 use OC\Files\Filesystem;
+use OC\Files\View;
 use OCA\Files_Sharing\AppInfo\Application;
 use OCA\Files_Sharing\External\MountProvider as ExternalMountProvider;
 use OCA\Files_Sharing\MountProvider;
@@ -211,7 +212,12 @@ abstract class TestCase extends \Test\TestCase {
                \OC::$server->getUserSession()->setUser(null);
                \OC\Files\Filesystem::tearDown();
                \OC::$server->getUserSession()->login($user, $password);
-               \OC::$server->getUserFolder($user);
+               // We need to get the directory listing to trigger the lazy user folder
+               // to create the files directory. Since the filecache might get cleared
+               // in the cache, any follow up test case may fail as with object storage
+               // the filecache represents the file structure
+               Filesystem::initMountPoints($user);
+               \OC::$server->getUserFolder($user)->getDirectoryListing();
 
                \OC_Util::setupFS($user);
        }