fixup! Check if groups is array, return empty do not throw
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
parent
2493e9426d
commit
24659342f5
2 changed files with 5 additions and 37 deletions
|
@ -340,7 +340,7 @@ class UsersController extends OCSController {
|
|||
$data['storageLocation'] = $targetUserObject->getHome();
|
||||
$data['lastLogin'] = $targetUserObject->getLastLogin() * 1000;
|
||||
$data['backend'] = $targetUserObject->getBackendClassName();
|
||||
$data['subadmins'] = $this->getUserSubAdminGroupsData($targetUserObject->getUID());
|
||||
$data['subadmin'] = $this->getUserSubAdminGroupsData($targetUserObject->getUID());
|
||||
$data['quota'] = $this->fillStorageInfo($targetUserObject->getUID());
|
||||
$data[AccountManager::PROPERTY_EMAIL] = $targetUserObject->getEMailAddress();
|
||||
$data[AccountManager::PROPERTY_DISPLAYNAME] = $targetUserObject->getDisplayName();
|
||||
|
@ -852,12 +852,7 @@ class UsersController extends OCSController {
|
|||
*/
|
||||
public function getUserSubAdminGroups(string $userId): DataResponse {
|
||||
$groups = $this->getUserSubAdminGroupsData($userId);
|
||||
|
||||
if(is_array($groups)) {
|
||||
throw new OCSException('Unknown error occurred', 102);
|
||||
} else {
|
||||
return new DataResponse($groups);
|
||||
}
|
||||
return new DataResponse($groups);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -765,7 +765,7 @@ class UsersControllerTest extends TestCase {
|
|||
'storageLocation' => '/var/www/newtcloud/data/UID',
|
||||
'lastLogin' => 1521191471000,
|
||||
'backend' => 'Database',
|
||||
'subadmins' => ['group3'],
|
||||
'subadmin' => ['group3'],
|
||||
'quota' => ['DummyValue'],
|
||||
'email' => 'demo@nextcloud.com',
|
||||
'displayname' => 'Demo User',
|
||||
|
@ -880,7 +880,7 @@ class UsersControllerTest extends TestCase {
|
|||
'storageLocation' => '/var/www/newtcloud/data/UID',
|
||||
'lastLogin' => 1521191471000,
|
||||
'backend' => 'Database',
|
||||
'subadmins' => [],
|
||||
'subadmin' => [],
|
||||
'quota' => ['DummyValue'],
|
||||
'email' => 'demo@nextcloud.com',
|
||||
'displayname' => 'Demo User',
|
||||
|
@ -1035,7 +1035,7 @@ class UsersControllerTest extends TestCase {
|
|||
'storageLocation' => '/var/www/newtcloud/data/UID',
|
||||
'lastLogin' => 1521191471000,
|
||||
'backend' => 'Database',
|
||||
'subadmins' => [],
|
||||
'subadmin' => [],
|
||||
'quota' => ['DummyValue'],
|
||||
'email' => 'subadmin@nextcloud.com',
|
||||
'displayname' => 'Subadmin User',
|
||||
|
@ -2853,33 +2853,6 @@ class UsersControllerTest extends TestCase {
|
|||
$this->assertEquals(['TargetGroup'], $this->api->getUserSubAdminGroups('RequestedUser')->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OCP\AppFramework\OCS\OCSException
|
||||
* @expectedExceptionCode 102
|
||||
* @expectedExceptionMessage Unknown error occurred
|
||||
*/
|
||||
public function testGetUserSubAdminGroupsWithoutGroups() {
|
||||
$targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
|
||||
$this->userManager
|
||||
->expects($this->once())
|
||||
->method('get')
|
||||
->with('RequestedUser')
|
||||
->will($this->returnValue($targetUser));
|
||||
$subAdminManager = $this->getMockBuilder('OC\SubAdmin')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$subAdminManager
|
||||
->expects($this->once())
|
||||
->method('getSubAdminsGroups')
|
||||
->with($targetUser)
|
||||
->will($this->returnValue([]));
|
||||
$this->groupManager
|
||||
->expects($this->once())
|
||||
->method('getSubAdmin')
|
||||
->will($this->returnValue($subAdminManager));
|
||||
|
||||
$this->api->getUserSubAdminGroups('RequestedUser');
|
||||
}
|
||||
|
||||
public function testEnableUser() {
|
||||
$targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
|
||||
$targetUser->expects($this->once())
|
||||
|
|
Loading…
Reference in a new issue