Skip to content

Commit

Permalink
Merge pull request #6547 from nextcloud/backport-6545-stable12
Browse files Browse the repository at this point in the history
[stable12] throw 101 when an empty group string is provided
  • Loading branch information
MorrisJobke authored Sep 20, 2017
2 parents 3c449c8 + 713ce42 commit 6a52cda
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/provisioning_api/lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ public function addToGroup($userId, $groupid = '') {
public function removeFromGroup($userId, $groupid) {
$loggedInUser = $this->userSession->getUser();

if($groupid === null) {
if($groupid === null || trim($groupid) === '') {
throw new OCSException('', 101);
}

Expand Down
14 changes: 14 additions & 0 deletions apps/provisioning_api/tests/Controller/UsersControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2117,6 +2117,20 @@ public function testRemoveFromGroupWithNoTargetGroup() {
$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
Expand Down

0 comments on commit 6a52cda

Please sign in to comment.