mirror of
https://github.com/nextcloud/server.git
synced 2026-05-19 16:39:59 -04:00
Merge pull request #6548 from nextcloud/backport-6545-stable11
[stable11] throw 101 when an empty group string is provided
This commit is contained in:
commit
706907c24b
2 changed files with 15 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue