diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index 25cc13d1c3..e165457a33 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -604,7 +604,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 19b5fa65e9..692b94556c 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -2117,6 +2117,20 @@ class UsersControllerTest extends TestCase { $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