diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2015-04-13 10:32:18 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2015-04-14 15:16:27 +0200 |
commit | 68d37afa3b70eafb336c5b51cea3a65931b28520 (patch) | |
tree | 0a1495d40769c11aa3e891368464e23cea701327 /apps/provisioning_api/tests/userstest.php | |
parent | 9dac69b21b8a2e5f04b85df5581ac120727135ea (diff) | |
download | nextcloud-server-68d37afa3b70eafb336c5b51cea3a65931b28520.tar.gz nextcloud-server-68d37afa3b70eafb336c5b51cea3a65931b28520.zip |
Do not try to make user subadmin of group twice
If the provisioning api is used to make a user subadmin of a group that user
is already a subadmin just return success.
Added unit test to ensure things keep working.
Diffstat (limited to 'apps/provisioning_api/tests/userstest.php')
-rw-r--r-- | apps/provisioning_api/tests/userstest.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/apps/provisioning_api/tests/userstest.php b/apps/provisioning_api/tests/userstest.php index 917d06a8348..82ff26134dc 100644 --- a/apps/provisioning_api/tests/userstest.php +++ b/apps/provisioning_api/tests/userstest.php @@ -767,4 +767,29 @@ class UsersTest extends TestCase { $this->assertFalse($result->succeeded()); $this->assertEquals(101, $result->getStatusCode()); } + + public function testSubAdminOfGroupAlreadySubAdmin() { + $user1 = $this->generateUsers(); + $user2 = $this->generateUsers(); + \OC_User::setUserId($user1); + \OC_Group::addToGroup($user1, 'admin'); + $group1 = $this->getUniqueID(); + \OC_Group::createGroup($group1); + + //Make user2 subadmin of group1 + $_POST['groupid'] = $group1; + $result = \OCA\provisioning_api\Users::addSubAdmin([ + 'userid' => $user2, + ]); + $this->assertInstanceOf('OC_OCS_Result', $result); + $this->assertTrue($result->succeeded()); + + //Make user2 subadmin of group1 again + $_POST['groupid'] = $group1; + $result = \OCA\provisioning_api\Users::addSubAdmin([ + 'userid' => $user2, + ]); + $this->assertInstanceOf('OC_OCS_Result', $result); + $this->assertTrue($result->succeeded()); + } } |