diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index c58c5f25e2..aa57dee874 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -525,7 +525,7 @@ class UsersController extends OCSController { public function removeFromGroup($userId, $groupid) { $loggedInUser = $this->userSession->getUser(); - if($groupid === null) { + if($groupid === null || trim($groupid) === '') { throw new OCSException('', 101); } diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index 0dd8ecd485..7a60d8aaa1 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -1752,6 +1752,20 @@ class UsersControllerTest extends OriginalTest { $this->api->removeFromGroup('TargetUser', null); } + /** + * @expectedException \OCP\AppFramework\OCS\OCSException + * @expectedExceptionCode 101 + */ + public function testRemoveFromGroupWithEmptyTargetGroup() { + $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $this->userSession + ->expects($this->once()) + ->method('getUser') + ->will($this->returnValue($loggedInUser)); + + $this->api->removeFromGroup('TargetUser', ''); + } + /** * @expectedException \OCP\AppFramework\OCS\OCSException * @expectedExceptionCode 102