Browse Source

throw 101 when an empty group string is provided

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
tags/v13.0.0beta1
Arthur Schiwon 6 years ago
parent
commit
a62b4a68a0
No account linked to committer's email address

+ 1
- 1
apps/provisioning_api/lib/Controller/UsersController.php View File

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


+ 14
- 0
apps/provisioning_api/tests/Controller/UsersControllerTest.php View File

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

Loading…
Cancel
Save