Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix similar issues with the group id
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Apr 24, 2017
commit e19126425bd24ab0a357bd6eb2673512b49dfef6
6 changes: 3 additions & 3 deletions apps/provisioning_api/lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,10 @@ public function addSubAdmin($userId, $groupid) {
}
// 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);
}

Expand Down Expand Up @@ -713,7 +713,7 @@ public function removeSubAdmin($userId, $groupid) {
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2238,7 +2238,7 @@ public function testAddSubAdminWithNotExistingTargetUser() {
/**
* @expectedException \OCP\AppFramework\OCS\OCSException
* @expectedExceptionCode 102
* @expectedExceptionMessage Group:NotExistingGroup does not exist
* @expectedExceptionMessage Group does not exist
*/
public function testAddSubAdminWithNotExistingTargetGroup() {

Expand All @@ -2265,6 +2265,10 @@ public function testAddSubAdminWithNotExistingTargetGroup() {
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')
Expand Down