Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable12] throw 101 when an empty group string is provided #6547

Merged
merged 1 commit into from
Sep 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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