]> source.dussan.org Git - nextcloud-server.git/commitdiff
add tests for sharing files the users doesn't have access to
authorRobin Appelman <icewind@owncloud.com>
Thu, 3 Apr 2014 11:14:34 +0000 (13:14 +0200)
committerRobin Appelman <icewind@owncloud.com>
Thu, 3 Apr 2014 11:14:34 +0000 (13:14 +0200)
apps/files_sharing/tests/api.php

index e3c5b6e4315ab9c706faa778c46fe28a13cd49bd..c7a848315ac8e7231ab151119ae72611e89f69f2 100644 (file)
@@ -878,6 +878,29 @@ class Test_Files_Sharing_Api extends Test_Files_Sharing_Base {
                $this->assertSame($expectedResult, $shareApiDummy->correctPathTest($path, $folder));
        }
 
+       /**
+        * @expectedException \Exception
+        */
+       public function testShareNonExisting() {
+               \Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1);
+
+               $id = PHP_INT_MAX - 1;
+               \OCP\Share::shareItem('file', $id, \OCP\Share::SHARE_TYPE_LINK, \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, 31);
+       }
+
+       /**
+        * @expectedException \Exception
+        */
+       public function testShareNotOwner() {
+               \Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);
+               \OC\Files\Filesystem::file_put_contents('foo.txt', 'bar');
+               $info = \OC\Files\Filesystem::getFileInfo('foo.txt');
+
+               \Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1);
+
+               \OCP\Share::shareItem('file', $info->getId(), \OCP\Share::SHARE_TYPE_LINK, \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, 31);
+       }
+
 }
 
 /**