diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-03-20 11:30:51 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-03-26 22:34:18 +0100 |
commit | 48ceaa9502a211b80881fe0fae431af12fcbc7a3 (patch) | |
tree | b77276347a3e422e346495edb611cea2642e874c | |
parent | 944b30183759fce2cc34b8aac34930fa946c17ab (diff) | |
download | nextcloud-server-48ceaa9502a211b80881fe0fae431af12fcbc7a3.tar.gz nextcloud-server-48ceaa9502a211b80881fe0fae431af12fcbc7a3.zip |
Fix share permission related unit tests
-rw-r--r-- | apps/files_sharing/tests/sharedstorage.php | 22 | ||||
-rw-r--r-- | tests/lib/connector/sabre/objecttree.php | 4 |
2 files changed, 15 insertions, 11 deletions
diff --git a/apps/files_sharing/tests/sharedstorage.php b/apps/files_sharing/tests/sharedstorage.php index 2b057bd20af..f840b9b964f 100644 --- a/apps/files_sharing/tests/sharedstorage.php +++ b/apps/files_sharing/tests/sharedstorage.php @@ -199,7 +199,7 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase { $this->assertTrue($result); } - function testFopenWithReadOnlyPermission() { + public function testFopenWithReadOnlyPermission() { $this->view->file_put_contents($this->folder . '/existing.txt', 'foo'); $fileinfoFolder = $this->view->getFileInfo($this->folder); $result = \OCP\Share::shareItem('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, @@ -230,7 +230,7 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase { $this->assertTrue($result); } - function testFopenWithCreateOnlyPermission() { + public function testFopenWithCreateOnlyPermission() { $this->view->file_put_contents($this->folder . '/existing.txt', 'foo'); $fileinfoFolder = $this->view->getFileInfo($this->folder); $result = \OCP\Share::shareItem('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, @@ -250,9 +250,9 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase { $this->assertNotFalse($handle); fclose($handle); - // rename file allowed as long as target did not exist - $this->assertTrue($user2View->rename($this->folder . '/test-create.txt', $this->folder . '/newtarget.txt')); - $this->assertTrue($user2View->file_exists($this->folder . '/newtarget.txt')); + // rename file never allowed + $this->assertFalse($user2View->rename($this->folder . '/test-create.txt', $this->folder . '/newtarget.txt')); + $this->assertFalse($user2View->file_exists($this->folder . '/newtarget.txt')); // rename file not allowed if target exists $this->assertFalse($user2View->rename($this->folder . '/newtarget.txt', $this->folder . '/existing.txt')); @@ -274,7 +274,7 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase { $this->assertTrue($result); } - function testFopenWithUpdateOnlyPermission() { + public function testFopenWithUpdateOnlyPermission() { $this->view->file_put_contents($this->folder . '/existing.txt', 'foo'); $fileinfoFolder = $this->view->getFileInfo($this->folder); @@ -301,13 +301,17 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase { $this->assertTrue($user2View->rename($this->folder . '/test.txt.part', $this->folder . '/existing.txt')); $this->assertTrue($user2View->file_exists($this->folder . '/existing.txt')); + // rename regular file allowed + $this->assertTrue($user2View->rename($this->folder . '/existing.txt', $this->folder . '/existing-renamed.txt')); + $this->assertTrue($user2View->file_exists($this->folder . '/existing-renamed.txt')); + // overwriting file directly is allowed - $handle = $user2View->fopen($this->folder . '/existing.txt', 'w'); + $handle = $user2View->fopen($this->folder . '/existing-renamed.txt', 'w'); $this->assertNotFalse($handle); fclose($handle); // delete forbidden - $this->assertFalse($user2View->unlink($this->folder . '/existing.txt')); + $this->assertFalse($user2View->unlink($this->folder . '/existing-renamed.txt')); //cleanup self::loginHelper(self::TEST_FILES_SHARING_API_USER1); @@ -316,7 +320,7 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase { $this->assertTrue($result); } - function testFopenWithDeleteOnlyPermission() { + public function testFopenWithDeleteOnlyPermission() { $this->view->file_put_contents($this->folder . '/existing.txt', 'foo'); $fileinfoFolder = $this->view->getFileInfo($this->folder); $result = \OCP\Share::shareItem('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, diff --git a/tests/lib/connector/sabre/objecttree.php b/tests/lib/connector/sabre/objecttree.php index 2548066214b..8c824d1bbc8 100644 --- a/tests/lib/connector/sabre/objecttree.php +++ b/tests/lib/connector/sabre/objecttree.php @@ -70,7 +70,7 @@ class ObjectTree extends \Test\TestCase { function moveFailedInvalidCharsProvider() { return array( - array('a/b', 'a/c*', array('a' => false, 'a/b' => true, 'a/c*' => false), array()), + array('a/b', 'a/*', array('a' => true, 'a/b' => true, 'a/c*' => false), array()), ); } @@ -81,12 +81,12 @@ class ObjectTree extends \Test\TestCase { array('a/b', 'b/b', array('a' => false, 'a/b' => true, 'b' => false, 'b/b' => false), array()), array('a/b', 'b/b', array('a' => true, 'a/b' => true, 'b' => false, 'b/b' => false), array()), array('a/b', 'b/b', array('a' => true, 'a/b' => true, 'b' => true, 'b/b' => false), array('a/b' => false)), + array('a/b', 'a/c', array('a' => false, 'a/b' => true, 'a/c' => false), array()), ); } function moveSuccessProvider() { return array( - array('a/b', 'a/c', array('a' => false, 'a/b' => true, 'a/c' => false), array()), array('a/b', 'b/b', array('a' => true, 'a/b' => true, 'b' => true, 'b/b' => false), array('a/b' => true)), // older files with special chars can still be renamed to valid names array('a/b*', 'b/b', array('a' => true, 'a/b*' => true, 'b' => true, 'b/b' => false), array('a/b*' => true)), |