diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2020-05-12 14:41:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-12 14:41:09 +0300 |
commit | 3142054de66d1c2afef5d682b7829e181e088a6f (patch) | |
tree | 328ace22afdd5156b2fbcb1babae5218583d661f /apps | |
parent | 1046d4b145ce5a86908017e90da1ff67cd3c5479 (diff) | |
parent | d8338275c846dcacb878ffb7cfd6ffd912ccaaa3 (diff) |
Merge pull request #20877 from nextcloud/backport/20719/stable18
[stable18] Fix languages empty array
Diffstat (limited to 'apps')
-rw-r--r-- | apps/provisioning_api/lib/Controller/AUserData.php | 2 | ||||
-rw-r--r-- | apps/provisioning_api/tests/Controller/UsersControllerTest.php | 107 | ||||
-rw-r--r-- | apps/settings/lib/Controller/UsersController.php | 1 |
3 files changed, 63 insertions, 47 deletions
diff --git a/apps/provisioning_api/lib/Controller/AUserData.php b/apps/provisioning_api/lib/Controller/AUserData.php index 2bc81e9dcf9..fb3dcd05953 100644 --- a/apps/provisioning_api/lib/Controller/AUserData.php +++ b/apps/provisioning_api/lib/Controller/AUserData.php @@ -145,7 +145,7 @@ abstract class AUserData extends OCSController { $data[AccountManager::PROPERTY_WEBSITE] = $userAccount[AccountManager::PROPERTY_WEBSITE]['value']; $data[AccountManager::PROPERTY_TWITTER] = $userAccount[AccountManager::PROPERTY_TWITTER]['value']; $data['groups'] = $gids; - $data['language'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'lang'); + $data['language'] = $this->config->getSystemValue('force_language', $this->config->getUserValue($targetUserObject->getUID(), 'core', 'lang')); $data['locale'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'locale'); $backend = $targetUserObject->getBackend(); diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index ac2da91005e..36b9d49438b 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -225,7 +225,7 @@ class UsersControllerTest extends TestCase { $this->assertEquals($expected, $this->api->getUsers('MyCustomSearch')->getData()); } - + public function testAddUserAlreadyExisting() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(102); @@ -259,7 +259,7 @@ class UsersControllerTest extends TestCase { $this->api->addUser('AlreadyExistingUser', 'password', '', '', []); } - + public function testAddUserNonExistingGroup() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('group NonExistingGroup does not exist'); @@ -295,7 +295,7 @@ class UsersControllerTest extends TestCase { $this->api->addUser('NewUser', 'pass', '', '', ['NonExistingGroup']); } - + public function testAddUserExistingGroupNonExistingGroup() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('group NonExistingGroup does not exist'); @@ -485,7 +485,7 @@ class UsersControllerTest extends TestCase { )); } - + public function testAddUserFailedToGenerateUserID() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('Could not create non-existing user id'); @@ -528,7 +528,7 @@ class UsersControllerTest extends TestCase { $this->api->addUser('', 'PasswordOfTheNewUser')->getData(); } - + public function testAddUserEmailRequired() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('Required email address was not provided'); @@ -635,7 +635,7 @@ class UsersControllerTest extends TestCase { )); } - + public function testAddUserUnsuccessful() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('Bad request'); @@ -680,7 +680,7 @@ class UsersControllerTest extends TestCase { $this->api->addUser('NewUser', 'PasswordOfTheNewUser'); } - + public function testAddUserAsSubAdminNoGroup() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('no group specified (required for subadmins)'); @@ -713,7 +713,7 @@ class UsersControllerTest extends TestCase { $this->api->addUser('NewUser', 'PasswordOfTheNewUser', '', '', []); } - + public function testAddUserAsSubAdminValidGroupNotSubAdmin() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('insufficient privileges for group ExistingGroup'); @@ -856,7 +856,7 @@ class UsersControllerTest extends TestCase { )); } - + public function testGetUserTargetDoesNotExist() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('User does not exist'); @@ -956,6 +956,11 @@ class UsersControllerTest extends TestCase { ->method('getUserValue') ->with('UID', 'core', 'lang') ->will($this->returnValue('de')); + $this->config + ->expects($this->once()) + ->method('getSystemValue') + ->with('force_language', 'de') + ->willReturn('de'); $this->api ->expects($this->once()) ->method('fillStorageInfo') @@ -1072,6 +1077,11 @@ class UsersControllerTest extends TestCase { ->with('UID', 'core', 'enabled', 'true') ->will($this->returnValue('true')); $this->config + ->expects($this->once()) + ->method('getSystemValue') + ->with('force_language', 'da') + ->willReturn('da'); + $this->config ->expects($this->at(1)) ->method('getUserValue') ->with('UID', 'core', 'lang') @@ -1148,7 +1158,7 @@ class UsersControllerTest extends TestCase { } - + public function testGetUserDataAsSubAdminAndUserIsNotAccessible() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(997); @@ -1243,6 +1253,11 @@ class UsersControllerTest extends TestCase { ->method('fillStorageInfo') ->with('UID') ->will($this->returnValue(['DummyValue'])); + $this->config + ->expects($this->once()) + ->method('getSystemValue') + ->with('force_language', 'ru') + ->willReturn('ru'); $backend = $this->createMock(UserInterface::class); $backend->expects($this->atLeastOnce()) @@ -1382,7 +1397,7 @@ class UsersControllerTest extends TestCase { } - + public function testEditUserRegularUserSelfEditChangeEmailInvalid() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(102); @@ -1451,7 +1466,7 @@ class UsersControllerTest extends TestCase { } - + public function testEditUserRegularUserSelfEditChangeQuota() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(997); @@ -1516,7 +1531,7 @@ class UsersControllerTest extends TestCase { } - + public function testEditUserAdminUserSelfEditChangeInvalidQuota() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('Invalid quota value ABC'); @@ -1809,7 +1824,7 @@ class UsersControllerTest extends TestCase { $this->assertEquals([], $this->api->editUser('UserToEdit', 'quota', '3042824')->getData()); } - + public function testEditUserSubadminUserInaccessible() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(997); @@ -1849,7 +1864,7 @@ class UsersControllerTest extends TestCase { $this->api->editUser('UserToEdit', 'quota', 'value'); } - + public function testDeleteUserNotExistingUser() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(101); @@ -1872,7 +1887,7 @@ class UsersControllerTest extends TestCase { $this->api->deleteUser('UserToDelete'); } - + public function testDeleteUserSelf() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(101); @@ -1933,7 +1948,7 @@ class UsersControllerTest extends TestCase { $this->assertEquals([], $this->api->deleteUser('UserToDelete')->getData()); } - + public function testDeleteUnsuccessfulUserAsAdmin() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(101); @@ -2014,7 +2029,7 @@ class UsersControllerTest extends TestCase { $this->assertEquals([], $this->api->deleteUser('UserToDelete')->getData()); } - + public function testDeleteUnsuccessfulUserAsSubadmin() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(101); @@ -2062,7 +2077,7 @@ class UsersControllerTest extends TestCase { $this->api->deleteUser('UserToDelete'); } - + public function testDeleteUserAsSubAdminAndUserIsNotAccessible() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(997); @@ -2106,7 +2121,7 @@ class UsersControllerTest extends TestCase { $this->api->deleteUser('UserToDelete'); } - + public function testGetUsersGroupsTargetUserNotExisting() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(998); @@ -2243,7 +2258,7 @@ class UsersControllerTest extends TestCase { $this->assertEquals(['groups' => ['Group1']], $this->api->getUsersGroups('UserToLookup')->getData()); } - + public function testGetUsersGroupsForSubAdminUserAndUserIsInaccessible() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(997); @@ -2292,7 +2307,7 @@ class UsersControllerTest extends TestCase { $this->api->getUsersGroups('UserToLookup'); } - + public function testAddToGroupWithTargetGroupNotExisting() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(102); @@ -2305,7 +2320,7 @@ class UsersControllerTest extends TestCase { $this->api->addToGroup('TargetUser', 'GroupToAddTo'); } - + public function testAddToGroupWithNoGroupSpecified() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(101); @@ -2313,7 +2328,7 @@ class UsersControllerTest extends TestCase { $this->api->addToGroup('TargetUser'); } - + public function testAddToGroupWithTargetUserNotExisting() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(103); @@ -2327,7 +2342,7 @@ class UsersControllerTest extends TestCase { $this->api->addToGroup('TargetUser', 'GroupToAddTo'); } - + public function testAddToGroupNoSubadmin() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(104); @@ -2461,7 +2476,7 @@ class UsersControllerTest extends TestCase { $this->assertEquals(new DataResponse(), $this->api->addToGroup('TargetUser', 'GroupToAddTo')); } - + public function testRemoveFromGroupWithNoTargetGroup() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(101); @@ -2475,7 +2490,7 @@ class UsersControllerTest extends TestCase { $this->api->removeFromGroup('TargetUser', ''); } - + public function testRemoveFromGroupWithEmptyTargetGroup() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(101); @@ -2489,7 +2504,7 @@ class UsersControllerTest extends TestCase { $this->api->removeFromGroup('TargetUser', ''); } - + public function testRemoveFromGroupWithNotExistingTargetGroup() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(102); @@ -2508,7 +2523,7 @@ class UsersControllerTest extends TestCase { $this->api->removeFromGroup('TargetUser', 'TargetGroup'); } - + public function testRemoveFromGroupWithNotExistingTargetUser() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(103); @@ -2533,7 +2548,7 @@ class UsersControllerTest extends TestCase { $this->api->removeFromGroup('TargetUser', 'TargetGroup'); } - + public function testRemoveFromGroupWithoutPermission() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(104); @@ -2574,7 +2589,7 @@ class UsersControllerTest extends TestCase { $this->api->removeFromGroup('TargetUser', 'TargetGroup'); } - + public function testRemoveFromGroupAsAdminFromAdmin() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('Cannot remove yourself from the admin group'); @@ -2624,7 +2639,7 @@ class UsersControllerTest extends TestCase { $this->api->removeFromGroup('Admin', 'admin'); } - + public function testRemoveFromGroupAsSubAdminFromSubAdmin() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('Cannot remove yourself from this group as you are a SubAdmin'); @@ -2679,7 +2694,7 @@ class UsersControllerTest extends TestCase { $this->api->removeFromGroup('SubAdmin', 'subadmin'); } - + public function testRemoveFromGroupAsSubAdminFromLastSubAdminGroup() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('Not viable to remove user from the last group you are SubAdmin of'); @@ -2782,7 +2797,7 @@ class UsersControllerTest extends TestCase { $this->assertEquals([], $this->api->removeFromGroup('AnotherUser', 'admin')->getData()); } - + public function testAddSubAdminWithNotExistingTargetUser() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('User does not exist'); @@ -2797,7 +2812,7 @@ class UsersControllerTest extends TestCase { $this->api->addSubAdmin('NotExistingUser', ''); } - + public function testAddSubAdminWithNotExistingTargetGroup() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('Group does not exist'); @@ -2819,7 +2834,7 @@ class UsersControllerTest extends TestCase { $this->api->addSubAdmin('ExistingUser', 'NotExistingGroup'); } - + public function testAddSubAdminToAdminGroup() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('Cannot create subadmins for admin group'); @@ -2906,7 +2921,7 @@ class UsersControllerTest extends TestCase { $this->assertEquals([], $this->api->addSubAdmin('ExistingUser', 'TargetGroup')->getData()); } - + public function testRemoveSubAdminNotExistingTargetUser() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('User does not exist'); @@ -2921,7 +2936,7 @@ class UsersControllerTest extends TestCase { $this->api->removeSubAdmin('NotExistingUser', 'GroupToDeleteFrom'); } - + public function testRemoveSubAdminNotExistingTargetGroup() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('Group does not exist'); @@ -2943,7 +2958,7 @@ class UsersControllerTest extends TestCase { } - + public function testRemoveSubAdminFromNotASubadmin() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('User is not a subadmin of this group'); @@ -3009,7 +3024,7 @@ class UsersControllerTest extends TestCase { $this->assertEquals([], $this->api->removeSubAdmin('ExistingUser', 'GroupToDeleteFrom')->getData()); } - + public function testGetUserSubAdminGroupsNotExistingTargetUser() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('User does not exist'); @@ -3163,7 +3178,7 @@ class UsersControllerTest extends TestCase { $this->assertSame($expected, $api->getCurrentUser()->getData()); } - + public function testGetCurrentUserNotLoggedIn() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); @@ -3216,7 +3231,7 @@ class UsersControllerTest extends TestCase { $this->assertSame($expected, $api->getUser('uid')->getData()); } - + public function testResendWelcomeMessageWithNotExistingTargetUser() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(998); @@ -3230,7 +3245,7 @@ class UsersControllerTest extends TestCase { $this->api->resendWelcomeMessage('NotExistingUser'); } - + public function testResendWelcomeMessageAsSubAdminAndUserIsNotAccessible() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionCode(997); @@ -3275,7 +3290,7 @@ class UsersControllerTest extends TestCase { $this->api->resendWelcomeMessage('UserToGet'); } - + public function testResendWelcomeMessageNoEmail() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('Email address not available'); @@ -3316,7 +3331,7 @@ class UsersControllerTest extends TestCase { $this->api->resendWelcomeMessage('UserToGet'); } - + public function testResendWelcomeMessageNullEmail() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('Email address not available'); @@ -3456,7 +3471,7 @@ class UsersControllerTest extends TestCase { $this->api->resendWelcomeMessage('UserToGet'); } - + public function testResendWelcomeMessageFailed() { $this->expectException(\OCP\AppFramework\OCS\OCSException::class); $this->expectExceptionMessage('Sending email failed'); diff --git a/apps/settings/lib/Controller/UsersController.php b/apps/settings/lib/Controller/UsersController.php index 107f047aa30..598841a9022 100644 --- a/apps/settings/lib/Controller/UsersController.php +++ b/apps/settings/lib/Controller/UsersController.php @@ -274,6 +274,7 @@ class UsersController extends Controller { $serverData['userCount'] = $userCount; $serverData['languages'] = $languages; $serverData['defaultLanguage'] = $this->config->getSystemValue('default_language', 'en'); + $serverData['forceLanguage'] = $this->config->getSystemValue('force_language', false); // Settings $serverData['defaultQuota'] = $defaultQuota; $serverData['canChangePassword'] = $canChangePassword; |