diff options
author | Björn Schießle <schiessle@owncloud.com> | 2014-05-22 08:19:27 -0400 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2014-05-22 08:19:27 -0400 |
commit | 050df76830f05e25df0c298988658c9482fb4b87 (patch) | |
tree | dc1de7a8833883c91eaf15b1a45a1111d8fcfdc5 /tests/lib | |
parent | c4f6a80bdc10f502b5e0770fa25da7d5f8a95a7b (diff) | |
parent | 12338e0ef07c409156fa9cd1008bb981bda20461 (diff) | |
download | nextcloud-server-050df76830f05e25df0c298988658c9482fb4b87.tar.gz nextcloud-server-050df76830f05e25df0c298988658c9482fb4b87.zip |
Merge pull request #8599 from owncloud/sharing_disable_for_groups
allow admin to disable sharing for specific groups of users
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/util.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/lib/util.php b/tests/lib/util.php index c4780cc5f48..4dc7813d918 100644 --- a/tests/lib/util.php +++ b/tests/lib/util.php @@ -235,4 +235,59 @@ class Test_Util extends PHPUnit_Framework_TestCase { array(' .', false), ); } + + /** + * @dataProvider dataProviderForTestIsSharingDisabledForUser + * @param array $groups existing groups + * @param array $membership groups the user belong to + * @param array $excludedGroups groups which should be excluded from sharing + * @param bool $expected expected result + */ + function testIsSharingDisabledForUser($groups, $membership, $excludedGroups, $expected) { + $uid = "user1"; + \OC_User::setUserId($uid); + + \OC_User::createUser($uid, "passwd"); + + foreach($groups as $group) { + \OC_Group::createGroup($group); + } + + foreach($membership as $group) { + \OC_Group::addToGroup($uid, $group); + } + + $appConfig = \OC::$server->getAppConfig(); + $appConfig->setValue('core', 'shareapi_exclude_groups_list', implode(',', $excludedGroups)); + $appConfig->setValue('core', 'shareapi_exclude_groups', 'yes'); + + $result = \OCP\Util::isSharingDisabledForUser(); + + $this->assertSame($expected, $result); + + // cleanup + \OC_User::deleteUser($uid); + \OC_User::setUserId(''); + + foreach($groups as $group) { + \OC_Group::deleteGroup($group); + } + + $appConfig->setValue('core', 'shareapi_exclude_groups_list', ''); + $appConfig->setValue('core', 'shareapi_exclude_groups', 'no'); + + } + + public function dataProviderForTestIsSharingDisabledForUser() { + return array( + // existing groups, groups the user belong to, groups excluded from sharing, expected result + array(array('g1', 'g2', 'g3'), array(), array('g1'), false), + array(array('g1', 'g2', 'g3'), array(), array(), false), + array(array('g1', 'g2', 'g3'), array('g2'), array('g1'), false), + array(array('g1', 'g2', 'g3'), array('g2'), array(), false), + array(array('g1', 'g2', 'g3'), array('g1', 'g2'), array('g1'), false), + array(array('g1', 'g2', 'g3'), array('g1', 'g2'), array('g1', 'g2'), true), + array(array('g1', 'g2', 'g3'), array('g1', 'g2'), array('g1', 'g2', 'g3'), true), + ); + } } |