[Pkg-owncloud-commits] [owncloud] 103/118: Fix share permission related unit tests

David Prévot taffit at moszumanska.debian.org
Fri Mar 27 22:13:18 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit 48ceaa9502a211b80881fe0fae431af12fcbc7a3
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Fri Mar 20 11:30:51 2015 +0100

    Fix share permission related unit tests
---
 apps/files_sharing/tests/sharedstorage.php | 22 +++++++++++++---------
 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 2b057bd..f840b9b 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 2548066..8c824d1 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)),

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list