Skip to content

Commit 449ac36

Browse files
icewind1991AndyScherzinger
authored andcommitted
test: add test for permissions of copied share
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 9f1666e commit 449ac36

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

apps/files_sharing/tests/SharedStorageTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use OCA\Files_Sharing\SharedStorage;
1111
use OCA\Files_Trashbin\AppInfo\Application;
1212
use OCP\AppFramework\Bootstrap\IBootContext;
13+
use OCP\Constants;
1314
use OCP\Files\NotFoundException;
1415
use OCP\Share\IShare;
1516

@@ -579,4 +580,30 @@ public function testInitWithNotFoundSource() {
579580
$this->assertInstanceOf(\OC\Files\Storage\FailedStorage::class, $storage->getSourceStorage());
580581
$this->assertInstanceOf(\OC\Files\Cache\FailedCache::class, $storage->getCache());
581582
}
583+
584+
public function testCopyPermissions(): void {
585+
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
586+
587+
$share = $this->share(
588+
IShare::TYPE_USER,
589+
$this->filename,
590+
self::TEST_FILES_SHARING_API_USER1,
591+
self::TEST_FILES_SHARING_API_USER2,
592+
Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE - Constants::PERMISSION_DELETE
593+
);
594+
595+
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
596+
$view = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
597+
$this->assertTrue($view->file_exists($this->filename));
598+
599+
$this->assertTrue($view->copy($this->filename, '/target.txt'));
600+
601+
$this->assertTrue($view->file_exists('/target.txt'));
602+
603+
$info = $view->getFileInfo('/target.txt');
604+
$this->assertEquals(Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE, $info->getPermissions());
605+
606+
$this->view->unlink($this->filename);
607+
$this->shareManager->deleteShare($share);
608+
}
582609
}

0 commit comments

Comments
 (0)