summaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2021-10-14 08:05:17 +0000
committerChristopher Ng <chrng8@gmail.com>2021-10-19 04:44:40 +0000
commit7215148a242815a5064ce5d00a387c634dc936f3 (patch)
tree4edf67253bd8c3bbe3ea2f1fba17e21b221e9282 /apps/provisioning_api
parent382ba66ab5e1a675347e86d93593eb228da253bb (diff)
downloadnextcloud-server-7215148a242815a5064ce5d00a387c634dc936f3.tar.gz
nextcloud-server-7215148a242815a5064ce5d00a387c634dc936f3.zip
Add new account properties
- New properties - Organisation - Role - Headline - Biography - Profile Enabled property - Fix errors with building default account properties - Fix L10N factory method `getLanguage` not public error - Update tests Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps/provisioning_api')
-rw-r--r--apps/provisioning_api/lib/Controller/AUserData.php5
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php191
-rw-r--r--apps/provisioning_api/tests/Controller/UsersControllerTest.php94
3 files changed, 222 insertions, 68 deletions
diff --git a/apps/provisioning_api/lib/Controller/AUserData.php b/apps/provisioning_api/lib/Controller/AUserData.php
index 5bb62f2b7dc..f2fbea7b04f 100644
--- a/apps/provisioning_api/lib/Controller/AUserData.php
+++ b/apps/provisioning_api/lib/Controller/AUserData.php
@@ -181,6 +181,11 @@ abstract class AUserData extends OCSController {
IAccountManager::PROPERTY_ADDRESS,
IAccountManager::PROPERTY_WEBSITE,
IAccountManager::PROPERTY_TWITTER,
+ IAccountManager::PROPERTY_ORGANISATION,
+ IAccountManager::PROPERTY_ROLE,
+ IAccountManager::PROPERTY_HEADLINE,
+ IAccountManager::PROPERTY_BIOGRAPHY,
+ IAccountManager::PROPERTY_PROFILE_ENABLED,
] as $propertyName) {
$property = $userAccount->getProperty($propertyName);
$data[$propertyName] = $property->getValue();
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index dd8397a8a89..714759ccc0f 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -40,6 +40,7 @@ declare(strict_types=1);
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
+
namespace OCA\Provisioning_API\Controller;
use InvalidArgumentException;
@@ -94,29 +95,33 @@ class UsersController extends AUserData {
/** @var IEventDispatcher */
private $eventDispatcher;
- public function __construct(string $appName,
- IRequest $request,
- IUserManager $userManager,
- IConfig $config,
- IGroupManager $groupManager,
- IUserSession $userSession,
- IAccountManager $accountManager,
- IURLGenerator $urlGenerator,
- LoggerInterface $logger,
- IFactory $l10nFactory,
- NewUserMailHelper $newUserMailHelper,
- ISecureRandom $secureRandom,
- RemoteWipe $remoteWipe,
- KnownUserService $knownUserService,
- IEventDispatcher $eventDispatcher) {
- parent::__construct($appName,
- $request,
- $userManager,
- $config,
- $groupManager,
- $userSession,
- $accountManager,
- $l10nFactory);
+ public function __construct(
+ string $appName,
+ IRequest $request,
+ IUserManager $userManager,
+ IConfig $config,
+ IGroupManager $groupManager,
+ IUserSession $userSession,
+ IAccountManager $accountManager,
+ IURLGenerator $urlGenerator,
+ LoggerInterface $logger,
+ IFactory $l10nFactory,
+ NewUserMailHelper $newUserMailHelper,
+ ISecureRandom $secureRandom,
+ RemoteWipe $remoteWipe,
+ KnownUserService $knownUserService,
+ IEventDispatcher $eventDispatcher
+ ) {
+ parent::__construct(
+ $appName,
+ $request,
+ $userManager,
+ $config,
+ $groupManager,
+ $userSession,
+ $accountManager,
+ $l10nFactory
+ );
$this->urlGenerator = $urlGenerator;
$this->logger = $logger;
@@ -325,14 +330,16 @@ class UsersController extends AUserData {
* @return DataResponse
* @throws OCSException
*/
- public function addUser(string $userid,
- string $password = '',
- string $displayName = '',
- string $email = '',
- array $groups = [],
- array $subadmin = [],
- string $quota = '',
- string $language = ''): DataResponse {
+ public function addUser(
+ string $userid,
+ string $password = '',
+ string $displayName = '',
+ string $email = '',
+ array $groups = [],
+ array $subadmin = [],
+ string $quota = '',
+ string $language = ''
+ ): DataResponse {
$user = $this->userSession->getUser();
$isAdmin = $this->groupManager->isAdmin($user->getUID());
$subAdminManager = $this->groupManager->getSubAdmin();
@@ -349,10 +356,10 @@ class UsersController extends AUserData {
if ($groups !== []) {
foreach ($groups as $group) {
if (!$this->groupManager->groupExists($group)) {
- throw new OCSException('group '.$group.' does not exist', 104);
+ throw new OCSException('group ' . $group . ' does not exist', 104);
}
if (!$isAdmin && !$subAdminManager->isSubAdminOfGroup($user, $this->groupManager->get($group))) {
- throw new OCSException('insufficient privileges for group '. $group, 105);
+ throw new OCSException('insufficient privileges for group ' . $group, 105);
}
}
} else {
@@ -440,7 +447,8 @@ class UsersController extends AUserData {
} catch (\Exception $e) {
// Mail could be failing hard or just be plain not configured
// Logging error as it is the hardest of the two
- $this->logger->error("Unable to send the invitation mail to $email",
+ $this->logger->error(
+ "Unable to send the invitation mail to $email",
[
'app' => 'ocs_api',
'exception' => $e,
@@ -452,7 +460,8 @@ class UsersController extends AUserData {
return new DataResponse(['id' => $userid]);
} catch (HintException $e) {
- $this->logger->warning('Failed addUser attempt with hint exception.',
+ $this->logger->warning(
+ 'Failed addUser attempt with hint exception.',
[
'app' => 'ocs_api',
'exception' => $e,
@@ -460,7 +469,8 @@ class UsersController extends AUserData {
);
throw new OCSException($e->getHint(), 107);
} catch (OCSException $e) {
- $this->logger->warning('Failed addUser attempt with ocs exeption.',
+ $this->logger->warning(
+ 'Failed addUser attempt with ocs exeption.',
[
'app' => 'ocs_api',
'exception' => $e,
@@ -468,7 +478,8 @@ class UsersController extends AUserData {
);
throw $e;
} catch (InvalidArgumentException $e) {
- $this->logger->error('Failed addUser attempt with invalid argument exeption.',
+ $this->logger->error(
+ 'Failed addUser attempt with invalid argument exeption.',
[
'app' => 'ocs_api',
'exception' => $e,
@@ -476,7 +487,8 @@ class UsersController extends AUserData {
);
throw new OCSException($e->getMessage(), 101);
} catch (\Exception $e) {
- $this->logger->error('Failed addUser attempt with exception.',
+ $this->logger->error(
+ 'Failed addUser attempt with exception.',
[
'app' => 'ocs_api',
'exception' => $e
@@ -573,8 +585,10 @@ class UsersController extends AUserData {
}
$subAdminManager = $this->groupManager->getSubAdmin();
- if (!$this->groupManager->isAdmin($currentLoggedInUser->getUID())
- && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
+ if (
+ !$this->groupManager->isAdmin($currentLoggedInUser->getUID())
+ && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)
+ ) {
throw new OCSException('', OCSController::RESPOND_NOT_FOUND);
}
} else {
@@ -583,8 +597,10 @@ class UsersController extends AUserData {
// Editing self (display, email)
if ($this->config->getSystemValue('allow_user_to_change_display_name', true) !== false) {
- if ($targetUser->getBackend() instanceof ISetDisplayNameBackend
- || $targetUser->getBackend()->implementsActions(Backend::SET_DISPLAYNAME)) {
+ if (
+ $targetUser->getBackend() instanceof ISetDisplayNameBackend
+ || $targetUser->getBackend()->implementsActions(Backend::SET_DISPLAYNAME)
+ ) {
$permittedFields[] = IAccountManager::PROPERTY_DISPLAYNAME;
}
$permittedFields[] = IAccountManager::PROPERTY_EMAIL;
@@ -595,6 +611,11 @@ class UsersController extends AUserData {
$permittedFields[] = IAccountManager::PROPERTY_ADDRESS;
$permittedFields[] = IAccountManager::PROPERTY_WEBSITE;
$permittedFields[] = IAccountManager::PROPERTY_TWITTER;
+ $permittedFields[] = IAccountManager::PROPERTY_ORGANISATION;
+ $permittedFields[] = IAccountManager::PROPERTY_ROLE;
+ $permittedFields[] = IAccountManager::PROPERTY_HEADLINE;
+ $permittedFields[] = IAccountManager::PROPERTY_BIOGRAPHY;
+ $permittedFields[] = IAccountManager::PROPERTY_PROFILE_ENABLED;
return new DataResponse($permittedFields);
}
@@ -700,11 +721,11 @@ class UsersController extends AUserData {
*
* @param string $userId
* @param string $key
- * @param string $value
+ * @param string|bool $value
* @return DataResponse
* @throws OCSException
*/
- public function editUser(string $userId, string $key, string $value): DataResponse {
+ public function editUser(string $userId, string $key, $value): DataResponse {
$currentLoggedInUser = $this->userSession->getUser();
$targetUser = $this->userManager->get($userId);
@@ -716,8 +737,10 @@ class UsersController extends AUserData {
if ($targetUser->getUID() === $currentLoggedInUser->getUID()) {
// Editing self (display, email)
if ($this->config->getSystemValue('allow_user_to_change_display_name', true) !== false) {
- if ($targetUser->getBackend() instanceof ISetDisplayNameBackend
- || $targetUser->getBackend()->implementsActions(Backend::SET_DISPLAYNAME)) {
+ if (
+ $targetUser->getBackend() instanceof ISetDisplayNameBackend
+ || $targetUser->getBackend()->implementsActions(Backend::SET_DISPLAYNAME)
+ ) {
$permittedFields[] = self::USER_FIELD_DISPLAYNAME;
$permittedFields[] = IAccountManager::PROPERTY_DISPLAYNAME;
}
@@ -731,13 +754,17 @@ class UsersController extends AUserData {
$permittedFields[] = self::USER_FIELD_PASSWORD;
$permittedFields[] = self::USER_FIELD_NOTIFICATION_EMAIL;
- if ($this->config->getSystemValue('force_language', false) === false ||
- $this->groupManager->isAdmin($currentLoggedInUser->getUID())) {
+ if (
+ $this->config->getSystemValue('force_language', false) === false ||
+ $this->groupManager->isAdmin($currentLoggedInUser->getUID())
+ ) {
$permittedFields[] = self::USER_FIELD_LANGUAGE;
}
- if ($this->config->getSystemValue('force_locale', false) === false ||
- $this->groupManager->isAdmin($currentLoggedInUser->getUID())) {
+ if (
+ $this->config->getSystemValue('force_locale', false) === false ||
+ $this->groupManager->isAdmin($currentLoggedInUser->getUID())
+ ) {
$permittedFields[] = self::USER_FIELD_LOCALE;
}
@@ -745,10 +772,20 @@ class UsersController extends AUserData {
$permittedFields[] = IAccountManager::PROPERTY_ADDRESS;
$permittedFields[] = IAccountManager::PROPERTY_WEBSITE;
$permittedFields[] = IAccountManager::PROPERTY_TWITTER;
+ $permittedFields[] = IAccountManager::PROPERTY_ORGANISATION;
+ $permittedFields[] = IAccountManager::PROPERTY_ROLE;
+ $permittedFields[] = IAccountManager::PROPERTY_HEADLINE;
+ $permittedFields[] = IAccountManager::PROPERTY_BIOGRAPHY;
+ $permittedFields[] = IAccountManager::PROPERTY_PROFILE_ENABLED;
$permittedFields[] = IAccountManager::PROPERTY_PHONE . self::SCOPE_SUFFIX;
$permittedFields[] = IAccountManager::PROPERTY_ADDRESS . self::SCOPE_SUFFIX;
$permittedFields[] = IAccountManager::PROPERTY_WEBSITE . self::SCOPE_SUFFIX;
$permittedFields[] = IAccountManager::PROPERTY_TWITTER . self::SCOPE_SUFFIX;
+ $permittedFields[] = IAccountManager::PROPERTY_ORGANISATION . self::SCOPE_SUFFIX;
+ $permittedFields[] = IAccountManager::PROPERTY_ROLE . self::SCOPE_SUFFIX;
+ $permittedFields[] = IAccountManager::PROPERTY_HEADLINE . self::SCOPE_SUFFIX;
+ $permittedFields[] = IAccountManager::PROPERTY_BIOGRAPHY . self::SCOPE_SUFFIX;
+ $permittedFields[] = IAccountManager::PROPERTY_PROFILE_ENABLED . self::SCOPE_SUFFIX;
$permittedFields[] = IAccountManager::PROPERTY_AVATAR . self::SCOPE_SUFFIX;
@@ -759,11 +796,15 @@ class UsersController extends AUserData {
} else {
// Check if admin / subadmin
$subAdminManager = $this->groupManager->getSubAdmin();
- if ($this->groupManager->isAdmin($currentLoggedInUser->getUID())
- || $subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
+ if (
+ $this->groupManager->isAdmin($currentLoggedInUser->getUID())
+ || $subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)
+ ) {
// They have permissions over the user
- if ($targetUser->getBackend() instanceof ISetDisplayNameBackend
- || $targetUser->getBackend()->implementsActions(Backend::SET_DISPLAYNAME)) {
+ if (
+ $targetUser->getBackend() instanceof ISetDisplayNameBackend
+ || $targetUser->getBackend()->implementsActions(Backend::SET_DISPLAYNAME)
+ ) {
$permittedFields[] = self::USER_FIELD_DISPLAYNAME;
$permittedFields[] = IAccountManager::PROPERTY_DISPLAYNAME;
}
@@ -776,6 +817,11 @@ class UsersController extends AUserData {
$permittedFields[] = IAccountManager::PROPERTY_ADDRESS;
$permittedFields[] = IAccountManager::PROPERTY_WEBSITE;
$permittedFields[] = IAccountManager::PROPERTY_TWITTER;
+ $permittedFields[] = IAccountManager::PROPERTY_ORGANISATION;
+ $permittedFields[] = IAccountManager::PROPERTY_ROLE;
+ $permittedFields[] = IAccountManager::PROPERTY_HEADLINE;
+ $permittedFields[] = IAccountManager::PROPERTY_BIOGRAPHY;
+ $permittedFields[] = IAccountManager::PROPERTY_PROFILE_ENABLED;
$permittedFields[] = self::USER_FIELD_QUOTA;
$permittedFields[] = self::USER_FIELD_NOTIFICATION_EMAIL;
} else {
@@ -802,7 +848,7 @@ class UsersController extends AUserData {
$quota = \OCP\Util::computerFileSize($quota);
}
if ($quota === false) {
- throw new OCSException('Invalid quota value '.$value, 102);
+ throw new OCSException('Invalid quota value ' . $value, 102);
}
if ($quota === -1) {
$quota = 'none';
@@ -892,6 +938,10 @@ class UsersController extends AUserData {
case IAccountManager::PROPERTY_ADDRESS:
case IAccountManager::PROPERTY_WEBSITE:
case IAccountManager::PROPERTY_TWITTER:
+ case IAccountManager::PROPERTY_ORGANISATION:
+ case IAccountManager::PROPERTY_ROLE:
+ case IAccountManager::PROPERTY_HEADLINE:
+ case IAccountManager::PROPERTY_BIOGRAPHY:
$userAccount = $this->accountManager->getAccount($targetUser);
try {
$userProperty = $userAccount->getProperty($key);
@@ -910,12 +960,34 @@ class UsersController extends AUserData {
}
$this->accountManager->updateAccount($userAccount);
break;
+ case IAccountManager::PROPERTY_PROFILE_ENABLED:
+ if (!is_bool($value)) {
+ throw new OCSException('Invalid value, value must be a boolean', 102);
+ }
+ $value = $value === true ? '1' : '0';
+
+ $userAccount = $this->accountManager->getAccount($targetUser);
+ try {
+ $userProperty = $userAccount->getProperty($key);
+ if ($userProperty->getValue() !== $value) {
+ $userProperty->setValue($value);
+ }
+ } catch (PropertyDoesNotExistException $e) {
+ $userAccount->setProperty($key, $value, IAccountManager::SCOPE_LOCAL, IAccountManager::NOT_VERIFIED);
+ }
+ $this->accountManager->updateAccount($userAccount);
+ break;
case IAccountManager::PROPERTY_DISPLAYNAME . self::SCOPE_SUFFIX:
case IAccountManager::PROPERTY_EMAIL . self::SCOPE_SUFFIX:
case IAccountManager::PROPERTY_PHONE . self::SCOPE_SUFFIX:
case IAccountManager::PROPERTY_ADDRESS . self::SCOPE_SUFFIX:
case IAccountManager::PROPERTY_WEBSITE . self::SCOPE_SUFFIX:
case IAccountManager::PROPERTY_TWITTER . self::SCOPE_SUFFIX:
+ case IAccountManager::PROPERTY_ORGANISATION . self::SCOPE_SUFFIX:
+ case IAccountManager::PROPERTY_ROLE . self::SCOPE_SUFFIX:
+ case IAccountManager::PROPERTY_HEADLINE . self::SCOPE_SUFFIX:
+ case IAccountManager::PROPERTY_BIOGRAPHY . self::SCOPE_SUFFIX:
+ case IAccountManager::PROPERTY_PROFILE_ENABLED . self::SCOPE_SUFFIX:
case IAccountManager::PROPERTY_AVATAR . self::SCOPE_SUFFIX:
$propertyName = substr($key, 0, strlen($key) - strlen(self::SCOPE_SUFFIX));
$userAccount = $this->accountManager->getAccount($targetUser);
@@ -1300,8 +1372,10 @@ class UsersController extends AUserData {
// Check if admin / subadmin
$subAdminManager = $this->groupManager->getSubAdmin();
- if (!$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)
- && !$this->groupManager->isAdmin($currentLoggedInUser->getUID())) {
+ if (
+ !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)
+ && !$this->groupManager->isAdmin($currentLoggedInUser->getUID())
+ ) {
// No rights
throw new OCSException('', OCSController::RESPOND_NOT_FOUND);
}
@@ -1315,7 +1389,8 @@ class UsersController extends AUserData {
$emailTemplate = $this->newUserMailHelper->generateTemplate($targetUser, false);
$this->newUserMailHelper->sendMail($targetUser, $emailTemplate);
} catch (\Exception $e) {
- $this->logger->error("Can't send new user mail to $email",
+ $this->logger->error(
+ "Can't send new user mail to $email",
[
'app' => 'settings',
'exception' => $e,
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
index 7ae5d0c245f..2ce5cadb57d 100644
--- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -38,6 +39,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
+
namespace OCA\Provisioning_API\Tests\Controller;
use Exception;
@@ -165,11 +167,12 @@ class UsersControllerTest extends TestCase {
->with('MyCustomSearch')
->willReturn(['Admin' => [], 'Foo' => [], 'Bar' => []]);
- $expected = ['users' => [
- 'Admin',
- 'Foo',
- 'Bar',
- ],
+ $expected = [
+ 'users' => [
+ 'Admin',
+ 'Foo',
+ 'Bar',
+ ],
];
$this->assertEquals($expected, $this->api->getUsers('MyCustomSearch')->getData());
}
@@ -687,7 +690,7 @@ class UsersControllerTest extends TestCase {
$this->assertTrue(key_exists(
'id',
- $this->api->addUser('NewUser', 'PasswordOfTheNewUser', '', '', ['ExistingGroup'])->getData()
+ $this->api->addUser('NewUser', 'PasswordOfTheNewUser', '', '', ['ExistingGroup'])->getData()
));
}
@@ -711,7 +714,8 @@ class UsersControllerTest extends TestCase {
$this->logger
->expects($this->once())
->method('error')
- ->with('Failed addUser attempt with exception.',
+ ->with(
+ 'Failed addUser attempt with exception.',
[
'app' => 'ocs_api',
'exception' => $exception
@@ -998,6 +1002,11 @@ class UsersControllerTest extends TestCase {
IAccountManager::PROPERTY_PHONE => ['value' => 'phone'],
IAccountManager::PROPERTY_TWITTER => ['value' => 'twitter'],
IAccountManager::PROPERTY_WEBSITE => ['value' => 'website'],
+ IAccountManager::PROPERTY_ORGANISATION => ['value' => 'organisation'],
+ IAccountManager::PROPERTY_ROLE => ['value' => 'role'],
+ IAccountManager::PROPERTY_HEADLINE => ['value' => 'headline'],
+ IAccountManager::PROPERTY_BIOGRAPHY => ['value' => 'biography'],
+ IAccountManager::PROPERTY_PROFILE_ENABLED => ['value' => '1'],
]);
$this->config
->expects($this->at(0))
@@ -1067,6 +1076,11 @@ class UsersControllerTest extends TestCase {
'setPassword' => true,
],
'additional_mail' => [],
+ 'organisation' => 'organisation',
+ 'role' => 'role',
+ 'headline' => 'headline',
+ 'biography' => 'biography',
+ 'profile_enabled' => '1',
'notify_email' => null,
];
$this->assertEquals($expected, $this->invokePrivate($this->api, 'getUserData', ['UID']));
@@ -1166,6 +1180,11 @@ class UsersControllerTest extends TestCase {
IAccountManager::PROPERTY_PHONE => ['value' => 'phone'],
IAccountManager::PROPERTY_TWITTER => ['value' => 'twitter'],
IAccountManager::PROPERTY_WEBSITE => ['value' => 'website'],
+ IAccountManager::PROPERTY_ORGANISATION => ['value' => 'organisation'],
+ IAccountManager::PROPERTY_ROLE => ['value' => 'role'],
+ IAccountManager::PROPERTY_HEADLINE => ['value' => 'headline'],
+ IAccountManager::PROPERTY_BIOGRAPHY => ['value' => 'biography'],
+ IAccountManager::PROPERTY_PROFILE_ENABLED => ['value' => '1'],
]);
$this->l10nFactory
@@ -1196,6 +1215,11 @@ class UsersControllerTest extends TestCase {
'setPassword' => true,
],
'additional_mail' => [],
+ 'organisation' => 'organisation',
+ 'role' => 'role',
+ 'headline' => 'headline',
+ 'biography' => 'biography',
+ 'profile_enabled' => '1',
'notify_email' => null,
];
$this->assertEquals($expected, $this->invokePrivate($this->api, 'getUserData', ['UID']));
@@ -1334,6 +1358,11 @@ class UsersControllerTest extends TestCase {
IAccountManager::PROPERTY_PHONE => ['value' => 'phone'],
IAccountManager::PROPERTY_TWITTER => ['value' => 'twitter'],
IAccountManager::PROPERTY_WEBSITE => ['value' => 'website'],
+ IAccountManager::PROPERTY_ORGANISATION => ['value' => 'organisation'],
+ IAccountManager::PROPERTY_ROLE => ['value' => 'role'],
+ IAccountManager::PROPERTY_HEADLINE => ['value' => 'headline'],
+ IAccountManager::PROPERTY_BIOGRAPHY => ['value' => 'biography'],
+ IAccountManager::PROPERTY_PROFILE_ENABLED => ['value' => '1'],
]);
$this->l10nFactory
@@ -1363,6 +1392,11 @@ class UsersControllerTest extends TestCase {
'setPassword' => false,
],
'additional_mail' => [],
+ 'organisation' => 'organisation',
+ 'role' => 'role',
+ 'headline' => 'headline',
+ 'biography' => 'biography',
+ 'profile_enabled' => '1',
'notify_email' => null,
];
$this->assertEquals($expected, $this->invokePrivate($this->api, 'getUserData', ['UID']));
@@ -1543,6 +1577,11 @@ class UsersControllerTest extends TestCase {
[IAccountManager::PROPERTY_PHONE, '1234', '12345'],
[IAccountManager::PROPERTY_ADDRESS, 'Something street 2', 'Another street 3'],
[IAccountManager::PROPERTY_WEBSITE, 'https://examplesite1', 'https://examplesite2'],
+ [IAccountManager::PROPERTY_ORGANISATION, 'Organisation A', 'Organisation B'],
+ [IAccountManager::PROPERTY_ROLE, 'Human', 'Alien'],
+ [IAccountManager::PROPERTY_HEADLINE, 'Hi', 'Hello'],
+ [IAccountManager::PROPERTY_BIOGRAPHY, 'A biography', 'Another biography'],
+ [IAccountManager::PROPERTY_PROFILE_ENABLED, '1', '0'],
];
}
@@ -1614,6 +1653,11 @@ class UsersControllerTest extends TestCase {
[IAccountManager::PROPERTY_PHONE, IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_FEDERATED],
[IAccountManager::PROPERTY_ADDRESS, IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_FEDERATED],
[IAccountManager::PROPERTY_WEBSITE, IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_FEDERATED],
+ [IAccountManager::PROPERTY_ORGANISATION, IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_FEDERATED],
+ [IAccountManager::PROPERTY_ROLE, IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_FEDERATED],
+ [IAccountManager::PROPERTY_HEADLINE, IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_FEDERATED],
+ [IAccountManager::PROPERTY_BIOGRAPHY, IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_FEDERATED],
+ [IAccountManager::PROPERTY_PROFILE_ENABLED, IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_FEDERATED],
];
}
@@ -3490,7 +3534,12 @@ class UsersControllerTest extends TestCase {
'phone' => 'phone',
'address' => 'address',
'website' => 'website',
- 'twitter' => 'twitter'
+ 'twitter' => 'twitter',
+ 'organisation' => 'organisation',
+ 'role' => 'role',
+ 'headline' => 'headline',
+ 'biography' => 'biography',
+ 'profile_enabled' => '1'
]
);
@@ -3503,6 +3552,11 @@ class UsersControllerTest extends TestCase {
'address' => 'address',
'website' => 'website',
'twitter' => 'twitter',
+ 'organisation' => 'organisation',
+ 'role' => 'role',
+ 'headline' => 'headline',
+ 'biography' => 'biography',
+ 'profile_enabled' => '1',
'display-name' => 'Demo User'
];
@@ -3560,7 +3614,12 @@ class UsersControllerTest extends TestCase {
'address' => 'address',
'website' => 'website',
'twitter' => 'twitter',
- 'displayname' => 'Demo User'
+ 'displayname' => 'Demo User',
+ 'organisation' => 'organisation',
+ 'role' => 'role',
+ 'headline' => 'headline',
+ 'biography' => 'biography',
+ 'profile_enabled' => '1'
];
$api->expects($this->at(0))->method('getUserData')
@@ -3878,6 +3937,11 @@ class UsersControllerTest extends TestCase {
IAccountManager::PROPERTY_ADDRESS,
IAccountManager::PROPERTY_WEBSITE,
IAccountManager::PROPERTY_TWITTER,
+ IAccountManager::PROPERTY_ORGANISATION,
+ IAccountManager::PROPERTY_ROLE,
+ IAccountManager::PROPERTY_HEADLINE,
+ IAccountManager::PROPERTY_BIOGRAPHY,
+ IAccountManager::PROPERTY_PROFILE_ENABLED,
]],
[true, ISetDisplayNameBackend::class, [
IAccountManager::PROPERTY_DISPLAYNAME,
@@ -3887,6 +3951,11 @@ class UsersControllerTest extends TestCase {
IAccountManager::PROPERTY_ADDRESS,
IAccountManager::PROPERTY_WEBSITE,
IAccountManager::PROPERTY_TWITTER,
+ IAccountManager::PROPERTY_ORGANISATION,
+ IAccountManager::PROPERTY_ROLE,
+ IAccountManager::PROPERTY_HEADLINE,
+ IAccountManager::PROPERTY_BIOGRAPHY,
+ IAccountManager::PROPERTY_PROFILE_ENABLED,
]],
[true, UserInterface::class, [
IAccountManager::PROPERTY_EMAIL,
@@ -3895,6 +3964,11 @@ class UsersControllerTest extends TestCase {
IAccountManager::PROPERTY_ADDRESS,
IAccountManager::PROPERTY_WEBSITE,
IAccountManager::PROPERTY_TWITTER,
+ IAccountManager::PROPERTY_ORGANISATION,
+ IAccountManager::PROPERTY_ROLE,
+ IAccountManager::PROPERTY_HEADLINE,
+ IAccountManager::PROPERTY_BIOGRAPHY,
+ IAccountManager::PROPERTY_PROFILE_ENABLED,
]],
];
}
@@ -3941,7 +4015,7 @@ class UsersControllerTest extends TestCase {
$account = $this->createMock(IAccount::class);
$account->method('getProperty')
- ->will($this->returnValueMap($mockedProperties));
+ ->will($this->returnValueMap($mockedProperties));
$this->accountManager->expects($this->any())->method('getAccount')
->with($targetUser)