aboutsummaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-01-29 10:38:05 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2019-01-29 20:47:35 +0100
commit15abcff2a199f9d80baabbc39778765a2458acd2 (patch)
treec535c00106a36d2b9b4a225172da1939ee100779 /apps/provisioning_api
parent754932c7569f61fddd152151fcdcae6dbce9e834 (diff)
downloadnextcloud-server-15abcff2a199f9d80baabbc39778765a2458acd2.tar.gz
nextcloud-server-15abcff2a199f9d80baabbc39778765a2458acd2.zip
Expose subadmin to OCP
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/provisioning_api')
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php14
-rw-r--r--apps/provisioning_api/tests/Controller/UsersControllerTest.php76
2 files changed, 4 insertions, 86 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index 67fa32c6fb2..ac1cfe989fd 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -809,11 +809,8 @@ class UsersController extends AUserData {
return new DataResponse();
}
// Go
- if ($subAdminManager->createSubAdmin($user, $group)) {
- return new DataResponse();
- } else {
- throw new OCSException('Unknown error occurred', 103);
- }
+ $subAdminManager->createSubAdmin($user, $group);
+ return new DataResponse();
}
/**
@@ -845,11 +842,8 @@ class UsersController extends AUserData {
}
// Go
- if ($subAdminManager->deleteSubAdmin($user, $group)) {
- return new DataResponse();
- } else {
- throw new OCSException('Unknown error occurred', 103);
- }
+ $subAdminManager->deleteSubAdmin($user, $group);
+ return new DataResponse();
}
/**
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
index 0d6d811acbc..fcdc68d353b 100644
--- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
@@ -2738,44 +2738,6 @@ class UsersControllerTest extends TestCase {
/**
* @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 103
- * @expectedExceptionMessage Unknown error occurred
- */
- public function testAddSubAdminUnsuccessful() {
- $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
- $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
- $this->userManager
- ->expects($this->once())
- ->method('get')
- ->with('ExistingUser')
- ->will($this->returnValue($targetUser));
- $this->groupManager
- ->expects($this->once())
- ->method('get')
- ->with('TargetGroup')
- ->will($this->returnValue($targetGroup));
- $subAdminManager = $this->getMockBuilder('OC\SubAdmin')
- ->disableOriginalConstructor()->getMock();
- $subAdminManager
- ->expects($this->once())
- ->method('isSubAdminOfGroup')
- ->with($targetUser, $targetGroup)
- ->will($this->returnValue(false));
- $subAdminManager
- ->expects($this->once())
- ->method('createSubAdmin')
- ->with($targetUser, $targetGroup)
- ->will($this->returnValue(false));
- $this->groupManager
- ->expects($this->once())
- ->method('getSubAdmin')
- ->will($this->returnValue($subAdminManager));
-
- $this->api->addSubAdmin('ExistingUser', 'TargetGroup');
- }
-
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
* @expectedExceptionCode 101
* @expectedExceptionMessage User does not exist
*/
@@ -2879,44 +2841,6 @@ class UsersControllerTest extends TestCase {
/**
* @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 103
- * @expectedExceptionMessage Unknown error occurred
- */
- public function testRemoveSubAdminUnsuccessful() {
- $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
- $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
- $this->userManager
- ->expects($this->once())
- ->method('get')
- ->with('ExistingUser')
- ->will($this->returnValue($targetUser));
- $this->groupManager
- ->expects($this->once())
- ->method('get')
- ->with('GroupToDeleteFrom')
- ->will($this->returnValue($targetGroup));
- $subAdminManager = $this->getMockBuilder('OC\SubAdmin')
- ->disableOriginalConstructor()->getMock();
- $subAdminManager
- ->expects($this->once())
- ->method('isSubAdminOfGroup')
- ->with($targetUser, $targetGroup)
- ->will($this->returnValue(true));
- $subAdminManager
- ->expects($this->once())
- ->method('deleteSubAdmin')
- ->with($targetUser, $targetGroup)
- ->will($this->returnValue(false));
- $this->groupManager
- ->expects($this->once())
- ->method('getSubAdmin')
- ->will($this->returnValue($subAdminManager));
-
- $this->api->removeSubAdmin('ExistingUser', 'GroupToDeleteFrom');
- }
-
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
* @expectedExceptionCode 404
* @expectedExceptionMessage User does not exist
*/