aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/provisioning_api/lib/Controller/GroupsController.php11
-rw-r--r--apps/provisioning_api/tests/Controller/GroupsControllerTest.php8
2 files changed, 15 insertions, 4 deletions
diff --git a/apps/provisioning_api/lib/Controller/GroupsController.php b/apps/provisioning_api/lib/Controller/GroupsController.php
index 543fc3b40ac..7b6e5319c2a 100644
--- a/apps/provisioning_api/lib/Controller/GroupsController.php
+++ b/apps/provisioning_api/lib/Controller/GroupsController.php
@@ -232,10 +232,11 @@ class GroupsController extends AUserData {
* @PasswordConfirmationRequired
*
* @param string $groupid
+ * @param string $displayname
* @return DataResponse
* @throws OCSException
*/
- public function addGroup(string $groupid): DataResponse {
+ public function addGroup(string $groupid, string $displayname = ''): DataResponse {
// Validate name
if (empty($groupid)) {
$this->logger->error('Group name not supplied', ['app' => 'provisioning_api']);
@@ -245,7 +246,13 @@ class GroupsController extends AUserData {
if ($this->groupManager->groupExists($groupid)) {
throw new OCSException('group exists', 102);
}
- $this->groupManager->createGroup($groupid);
+ $group = $this->groupManager->createGroup($groupid);
+ if ($group === null) {
+ throw new OCSException('Not supported by backend', 103);
+ }
+ if ($displayname !== '') {
+ $group->setDisplayName($displayname);
+ }
return new DataResponse();
}
diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
index 66e7665de63..12010995560 100644
--- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
@@ -405,10 +405,12 @@ class GroupsControllerTest extends \Test\TestCase {
->with('NewGroup')
->willReturn(false);
+ $group = $this->createGroup('NewGroup');
$this->groupManager
->expects($this->once())
->method('createGroup')
- ->with('NewGroup');
+ ->with('NewGroup')
+ ->willReturn($group);
$this->api->addGroup('NewGroup');
}
@@ -419,10 +421,12 @@ class GroupsControllerTest extends \Test\TestCase {
->with('Iñtërnâtiônàlizætiøn')
->willReturn(false);
+ $group = $this->createGroup('Iñtërnâtiônàlizætiøn');
$this->groupManager
->expects($this->once())
->method('createGroup')
- ->with('Iñtërnâtiônàlizætiøn');
+ ->with('Iñtërnâtiônàlizætiøn')
+ ->willReturn($group);
$this->api->addGroup('Iñtërnâtiônàlizætiøn');
}