From f89e387c432b8ba0c524e239053a7fb284e00611 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 17 Oct 2024 18:29:52 +0200 Subject: [PATCH] test: add test for permissions of copied share Signed-off-by: Robin Appelman --- .../files_sharing/tests/SharedStorageTest.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/apps/files_sharing/tests/SharedStorageTest.php b/apps/files_sharing/tests/SharedStorageTest.php index f6557d1711d7b..c11cc90f75c8a 100644 --- a/apps/files_sharing/tests/SharedStorageTest.php +++ b/apps/files_sharing/tests/SharedStorageTest.php @@ -10,6 +10,7 @@ use OCA\Files_Sharing\SharedStorage; use OCA\Files_Trashbin\AppInfo\Application; use OCP\AppFramework\Bootstrap\IBootContext; +use OCP\Constants; use OCP\Files\NotFoundException; use OCP\Share\IShare; @@ -578,4 +579,30 @@ public function testInitWithNotFoundSource() { $this->assertInstanceOf(\OC\Files\Storage\FailedStorage::class, $storage->getSourceStorage()); $this->assertInstanceOf(\OC\Files\Cache\FailedCache::class, $storage->getCache()); } + + public function testCopyPermissions(): void { + self::loginHelper(self::TEST_FILES_SHARING_API_USER1); + + $share = $this->share( + IShare::TYPE_USER, + $this->filename, + self::TEST_FILES_SHARING_API_USER1, + self::TEST_FILES_SHARING_API_USER2, + Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE - Constants::PERMISSION_DELETE + ); + + self::loginHelper(self::TEST_FILES_SHARING_API_USER2); + $view = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files'); + $this->assertTrue($view->file_exists($this->filename)); + + $this->assertTrue($view->copy($this->filename, '/target.txt')); + + $this->assertTrue($view->file_exists('/target.txt')); + + $info = $view->getFileInfo('/target.txt'); + $this->assertEquals(Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE, $info->getPermissions()); + + $this->view->unlink($this->filename); + $this->shareManager->deleteShare($share); + } }