summaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2017-09-18 10:56:13 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2017-09-18 10:56:13 +0200
commita62b4a68a060845ff5b37e0b5040ebcf13f49e6c (patch)
tree2eeba534b2c1075ccc154200e337a66d44614d8a /apps/provisioning_api
parent60e0de4a36be29ec787860808bf61a115ef4adfb (diff)
downloadnextcloud-server-a62b4a68a060845ff5b37e0b5040ebcf13f49e6c.tar.gz
nextcloud-server-a62b4a68a060845ff5b37e0b5040ebcf13f49e6c.zip
throw 101 when an empty group string is provided
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/provisioning_api')
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php2
-rw-r--r--apps/provisioning_api/tests/Controller/UsersControllerTest.php14
2 files changed, 15 insertions, 1 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index 25cc13d1c32..e165457a339 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -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);
}
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
index 19b5fa65e9a..692b94556c5 100644
--- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
@@ -2119,6 +2119,20 @@ class UsersControllerTest extends TestCase {
/**
* @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
*/
public function testRemoveFromGroupWithNotExistingTargetGroup() {