diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2015-11-05 17:01:47 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-11-05 17:01:47 +0100 |
commit | 960c9f386dd878ff7566b9e33b1192fd2b5e0691 (patch) | |
tree | 35871da278e49ed836b24ced134e12f2d0b62298 /apps/provisioning_api | |
parent | e28daf2b377fa0ab6450947e692c089624e3b727 (diff) | |
download | nextcloud-server-960c9f386dd878ff7566b9e33b1192fd2b5e0691.tar.gz nextcloud-server-960c9f386dd878ff7566b9e33b1192fd2b5e0691.zip |
Revert OCS error code change from #20135
Diffstat (limited to 'apps/provisioning_api')
-rw-r--r-- | apps/provisioning_api/lib/users.php | 7 | ||||
-rw-r--r-- | apps/provisioning_api/tests/userstest.php | 12 |
2 files changed, 17 insertions, 2 deletions
diff --git a/apps/provisioning_api/lib/users.php b/apps/provisioning_api/lib/users.php index a9fafb48912..304fe901cfd 100644 --- a/apps/provisioning_api/lib/users.php +++ b/apps/provisioning_api/lib/users.php @@ -388,11 +388,16 @@ class Users { return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED); } - $group = $this->groupManager->get(!empty($parameters['_delete']['groupid']) ? $parameters['_delete']['groupid'] : null); + $group = !empty($parameters['_delete']['groupid']) ? $parameters['_delete']['groupid'] : null; if($group === null) { return new OC_OCS_Result(null, 101); } + $group = $this->groupManager->get($group); + if($group === null) { + return new OC_OCS_Result(null, 102); + } + $targetUser = $this->userManager->get($parameters['userid']); if($targetUser === null) { return new OC_OCS_Result(null, 103); diff --git a/apps/provisioning_api/tests/userstest.php b/apps/provisioning_api/tests/userstest.php index c5a1ac3061e..ba4ed8a2e2f 100644 --- a/apps/provisioning_api/tests/userstest.php +++ b/apps/provisioning_api/tests/userstest.php @@ -1357,6 +1357,16 @@ class UsersTest extends OriginalTest { $this->assertEquals($expected, $this->api->removeFromGroup(['userid' => 'TargetUser', '_delete' => ['groupid' => 'TargetGroup']])); } + public function testRemoveFromGroupWithNoTargetGroup() { + $loggedInUser = $this->getMock('\OCP\IUser'); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + $expected = new \OC_OCS_Result(null, 101); + $this->assertEquals($expected, $this->api->removeFromGroup(['userid' => 'TargetUser', '_delete' => []])); + } + public function testRemoveFromGroupWithNotExistingTargetGroup() { $loggedInUser = $this->getMock('\OCP\IUser'); $this->userSession @@ -1369,7 +1379,7 @@ class UsersTest extends OriginalTest { ->with('TargetGroup') ->will($this->returnValue(null)); - $expected = new \OC_OCS_Result(null, 101); + $expected = new \OC_OCS_Result(null, 102); $this->assertEquals($expected, $this->api->removeFromGroup(['userid' => 'TargetUser', '_delete' => ['groupid' => 'TargetGroup']])); } |