Merge pull request #6545 from nextcloud/provapi-fix-empty-gid-exception

throw 101 when an empty group string is provided
pull/6549/head
blizzz 2017-09-18 12:55:25 +07:00 committed by GitHub
commit 27ad83f541
2 changed files with 15 additions and 1 deletions

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

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