throw 101 when an empty group string is provided

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2017-09-18 10:56:13 +02:00
parent 2c73912de5
commit d50bf58279
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
2 changed files with 15 additions and 1 deletions

View File

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

View File

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