Merge pull request #20340 from owncloud/fix-ocs-error-code

Revert OCS error code change from #20135
This commit is contained in:
Thomas Müller 2015-11-06 11:56:34 +01:00
commit dc96aa3849
2 changed files with 17 additions and 2 deletions

View File

@ -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);

View File

@ -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']]));
}