summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-08-07 18:42:35 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-08-07 18:42:35 +0200
commitca8f7fd69c63a8149e73df98d77e489b319f37e4 (patch)
tree296b180f4e0eef20aab11a795bbb53f939b06577 /tests
parent09ca2e0291e15348348ced5bf7abbae4a5dd4a73 (diff)
parent143e4a81f0a4515cc43d21dd93aa10331f2736b2 (diff)
downloadnextcloud-server-ca8f7fd69c63a8149e73df98d77e489b319f37e4.tar.gz
nextcloud-server-ca8f7fd69c63a8149e73df98d77e489b319f37e4.zip
Merge pull request #18124 from owncloud/share-permwrongvar
Fix removal of share permissions when share disabled for user
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/view.php63
1 files changed, 60 insertions, 3 deletions
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 382c033f19c..bf99a582117 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -44,8 +44,22 @@ class View extends \Test\TestCase {
* @var \OC\Files\Storage\Storage[] $storages
*/
private $storages = array();
+
+ /**
+ * @var string
+ */
private $user;
+ /**
+ * @var \OCP\IUser
+ */
+ private $userObject;
+
+ /**
+ * @var \OCP\IGroup
+ */
+ private $groupObject;
+
/** @var \OC\Files\Storage\Storage */
private $tempStorage;
@@ -57,10 +71,15 @@ class View extends \Test\TestCase {
\OC_User::useBackend(new \OC_User_Dummy());
//login
- \OC_User::createUser('test', 'test');
+ $userManager = \OC::$server->getUserManager();
+ $groupManager = \OC::$server->getGroupManager();
+ $this->user = 'test';
+ $this->userObject = $userManager->createUser('test', 'test');
- $this->loginAsUser('test');
- $this->user = \OC_User::getUser();
+ $this->groupObject = $groupManager->createGroup('group1');
+ $this->groupObject->addUser($this->userObject);
+
+ $this->loginAsUser($this->user);
// clear mounts but somehow keep the root storage
// that was initialized above...
\OC\Files\Filesystem::clearMounts();
@@ -81,6 +100,10 @@ class View extends \Test\TestCase {
}
$this->logout();
+
+ $this->userObject->delete();
+ $this->groupObject->delete();
+
parent::tearDown();
}
@@ -208,6 +231,40 @@ class View extends \Test\TestCase {
$this->assertEquals(4, count($folderContent));
}
+ public function sharingDisabledPermissionProvider() {
+ return [
+ ['no', '', true],
+ ['yes', 'group1', false],
+ ];
+ }
+
+ /**
+ * @dataProvider sharingDisabledPermissionProvider
+ */
+ public function testRemoveSharePermissionWhenSharingDisabledForUser($excludeGroups, $excludeGroupsList, $expectedShareable) {
+ $appConfig = \OC::$server->getAppConfig();
+ $oldExcludeGroupsFlag = $appConfig->getValue('core', 'shareapi_exclude_groups', 'no');
+ $oldExcludeGroupsList = $appConfig->getValue('core', 'shareapi_exclude_groups_list', '');
+ $appConfig->setValue('core', 'shareapi_exclude_groups', $excludeGroups);
+ $appConfig->setValue('core', 'shareapi_exclude_groups_list', $excludeGroupsList);
+
+ $storage1 = $this->getTestStorage();
+ $storage2 = $this->getTestStorage();
+ \OC\Files\Filesystem::mount($storage1, array(), '/');
+ \OC\Files\Filesystem::mount($storage2, array(), '/mount');
+
+ $view = new \OC\Files\View('/');
+
+ $folderContent = $view->getDirectoryContent('');
+ $this->assertEquals($expectedShareable, $folderContent[0]->isShareable());
+
+ $folderContent = $view->getDirectoryContent('mount');
+ $this->assertEquals($expectedShareable, $folderContent[0]->isShareable());
+
+ $appConfig->setValue('core', 'shareapi_exclude_groups', $oldExcludeGroupsFlag);
+ $appConfig->setValue('core', 'shareapi_exclude_groups_list', $oldExcludeGroupsList);
+ }
+
function testCacheIncompleteFolder() {
$storage1 = $this->getTestStorage(false);
\OC\Files\Filesystem::clearMounts();