Fix similar issues with the group id

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-04-24 10:15:03 +02:00
parent 992c48c89b
commit e19126425b
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
2 changed files with 8 additions and 4 deletions

View File

@ -668,10 +668,10 @@ class UsersController extends OCSController {
}
// Check if group exists
if($group === null) {
throw new OCSException('Group:'.$groupid.' does not exist', 102);
throw new OCSException('Group does not exist', 102);
}
// Check if trying to make subadmin of admin group
if(strtolower($groupid) === 'admin') {
if($group->getGID() === 'admin') {
throw new OCSException('Cannot create subadmins for admin group', 103);
}
@ -713,7 +713,7 @@ class UsersController extends OCSController {
throw new OCSException('Group does not exist', 101);
}
// Check if they are a subadmin of this said group
if(!$subAdminManager->isSubAdminofGroup($user, $group)) {
if(!$subAdminManager->isSubAdminOfGroup($user, $group)) {
throw new OCSException('User is not a subadmin of this group', 102);
}

View File

@ -2238,7 +2238,7 @@ class UsersControllerTest extends TestCase {
/**
* @expectedException \OCP\AppFramework\OCS\OCSException
* @expectedExceptionCode 102
* @expectedExceptionMessage Group:NotExistingGroup does not exist
* @expectedExceptionMessage Group does not exist
*/
public function testAddSubAdminWithNotExistingTargetGroup() {
@ -2265,6 +2265,10 @@ class UsersControllerTest extends TestCase {
public function testAddSubAdminToAdminGroup() {
$targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$targetGroup
->expects($this->once())
->method('getGID')
->will($this->returnValue('admin'));
$this->userManager
->expects($this->once())
->method('get')