Skip to content
Snippets Groups Projects
Unverified Commit c9253cce authored by Roeland Jago Douma's avatar Roeland Jago Douma
Browse files

Move personal settings to proper registration

parent dc197990
No related branches found
No related tags found
No related merge requests found
Showing
with 43 additions and 67 deletions
...@@ -24,6 +24,11 @@ ...@@ -24,6 +24,11 @@
<admin-section>OCA\Settings\Sections\Admin\Security</admin-section> <admin-section>OCA\Settings\Sections\Admin\Security</admin-section>
<admin-section>OCA\Settings\Sections\Admin\Server</admin-section> <admin-section>OCA\Settings\Sections\Admin\Server</admin-section>
<admin-section>OCA\Settings\Sections\Admin\Sharing</admin-section> <admin-section>OCA\Settings\Sections\Admin\Sharing</admin-section>
<personal>OCA\Settings\Settings\Personal\Additional</personal>
<personal>OCA\Settings\Settings\Personal\PersonalInfo</personal>
<personal>OCA\Settings\Settings\Personal\ServerDevNotice</personal>
<personal>OCA\Settings\Settings\Personal\Security\Authtokens</personal>
<personal>OCA\Settings\Settings\Personal\Security\Password</personal>
<personal>OCA\Settings\Settings\Personal\Security\TwoFactor</personal> <personal>OCA\Settings\Settings\Personal\Security\TwoFactor</personal>
<personal-section>OCA\Settings\Sections\Personal\PersonalInfo</personal-section> <personal-section>OCA\Settings\Sections\Personal\PersonalInfo</personal-section>
<personal-section>OCA\Settings\Sections\Personal\Security</personal-section> <personal-section>OCA\Settings\Sections\Personal\Security</personal-section>
......
...@@ -36,11 +36,6 @@ return array( ...@@ -36,11 +36,6 @@ return array(
'OCA\\Settings\\Hooks' => $baseDir . '/../lib/Hooks.php', 'OCA\\Settings\\Hooks' => $baseDir . '/../lib/Hooks.php',
'OCA\\Settings\\Mailer\\NewUserMailHelper' => $baseDir . '/../lib/Mailer/NewUserMailHelper.php', 'OCA\\Settings\\Mailer\\NewUserMailHelper' => $baseDir . '/../lib/Mailer/NewUserMailHelper.php',
'OCA\\Settings\\Middleware\\SubadminMiddleware' => $baseDir . '/../lib/Middleware/SubadminMiddleware.php', 'OCA\\Settings\\Middleware\\SubadminMiddleware' => $baseDir . '/../lib/Middleware/SubadminMiddleware.php',
'OCA\\Settings\\Personal\\Additional' => $baseDir . '/../lib/Settings/Personal/Additional.php',
'OCA\\Settings\\Personal\\PersonalInfo' => $baseDir . '/../lib/Settings/Personal/PersonalInfo.php',
'OCA\\Settings\\Personal\\Security\\Authtokens' => $baseDir . '/../lib/Settings/Personal/Security/Authtokens.php',
'OCA\\Settings\\Personal\\Security\\Password' => $baseDir . '/../lib/Settings/Personal/Security/Password.php',
'OCA\\Settings\\Personal\\ServerDevNotice' => $baseDir . '/../lib/Settings/Personal/ServerDevNotice.php',
'OCA\\Settings\\Sections\\Admin\\Additional' => $baseDir . '/../lib/Sections/Admin/Additional.php', 'OCA\\Settings\\Sections\\Admin\\Additional' => $baseDir . '/../lib/Sections/Admin/Additional.php',
'OCA\\Settings\\Sections\\Admin\\Groupware' => $baseDir . '/../lib/Sections/Admin/Groupware.php', 'OCA\\Settings\\Sections\\Admin\\Groupware' => $baseDir . '/../lib/Sections/Admin/Groupware.php',
'OCA\\Settings\\Sections\\Admin\\Overview' => $baseDir . '/../lib/Sections/Admin/Overview.php', 'OCA\\Settings\\Sections\\Admin\\Overview' => $baseDir . '/../lib/Sections/Admin/Overview.php',
...@@ -50,5 +45,10 @@ return array( ...@@ -50,5 +45,10 @@ return array(
'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => $baseDir . '/../lib/Sections/Personal/PersonalInfo.php', 'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => $baseDir . '/../lib/Sections/Personal/PersonalInfo.php',
'OCA\\Settings\\Sections\\Personal\\Security' => $baseDir . '/../lib/Sections/Personal/Security.php', 'OCA\\Settings\\Sections\\Personal\\Security' => $baseDir . '/../lib/Sections/Personal/Security.php',
'OCA\\Settings\\Sections\\Personal\\SyncClients' => $baseDir . '/../lib/Sections/Personal/SyncClients.php', 'OCA\\Settings\\Sections\\Personal\\SyncClients' => $baseDir . '/../lib/Sections/Personal/SyncClients.php',
'OCA\\Settings\\Settings\\Personal\\Additional' => $baseDir . '/../lib/Settings/Personal/Additional.php',
'OCA\\Settings\\Settings\\Personal\\PersonalInfo' => $baseDir . '/../lib/Settings/Personal/PersonalInfo.php',
'OCA\\Settings\\Settings\\Personal\\Security\\Authtokens' => $baseDir . '/../lib/Settings/Personal/Security/Authtokens.php',
'OCA\\Settings\\Settings\\Personal\\Security\\Password' => $baseDir . '/../lib/Settings/Personal/Security/Password.php',
'OCA\\Settings\\Settings\\Personal\\Security\\TwoFactor' => $baseDir . '/../lib/Settings/Personal/Security/TwoFactor.php', 'OCA\\Settings\\Settings\\Personal\\Security\\TwoFactor' => $baseDir . '/../lib/Settings/Personal/Security/TwoFactor.php',
'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => $baseDir . '/../lib/Settings/Personal/ServerDevNotice.php',
); );
...@@ -51,11 +51,6 @@ class ComposerStaticInitSettings ...@@ -51,11 +51,6 @@ class ComposerStaticInitSettings
'OCA\\Settings\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php', 'OCA\\Settings\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php',
'OCA\\Settings\\Mailer\\NewUserMailHelper' => __DIR__ . '/..' . '/../lib/Mailer/NewUserMailHelper.php', 'OCA\\Settings\\Mailer\\NewUserMailHelper' => __DIR__ . '/..' . '/../lib/Mailer/NewUserMailHelper.php',
'OCA\\Settings\\Middleware\\SubadminMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/SubadminMiddleware.php', 'OCA\\Settings\\Middleware\\SubadminMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/SubadminMiddleware.php',
'OCA\\Settings\\Personal\\Additional' => __DIR__ . '/..' . '/../lib/Settings/Personal/Additional.php',
'OCA\\Settings\\Personal\\PersonalInfo' => __DIR__ . '/..' . '/../lib/Settings/Personal/PersonalInfo.php',
'OCA\\Settings\\Personal\\Security\\Authtokens' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/Authtokens.php',
'OCA\\Settings\\Personal\\Security\\Password' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/Password.php',
'OCA\\Settings\\Personal\\ServerDevNotice' => __DIR__ . '/..' . '/../lib/Settings/Personal/ServerDevNotice.php',
'OCA\\Settings\\Sections\\Admin\\Additional' => __DIR__ . '/..' . '/../lib/Sections/Admin/Additional.php', 'OCA\\Settings\\Sections\\Admin\\Additional' => __DIR__ . '/..' . '/../lib/Sections/Admin/Additional.php',
'OCA\\Settings\\Sections\\Admin\\Groupware' => __DIR__ . '/..' . '/../lib/Sections/Admin/Groupware.php', 'OCA\\Settings\\Sections\\Admin\\Groupware' => __DIR__ . '/..' . '/../lib/Sections/Admin/Groupware.php',
'OCA\\Settings\\Sections\\Admin\\Overview' => __DIR__ . '/..' . '/../lib/Sections/Admin/Overview.php', 'OCA\\Settings\\Sections\\Admin\\Overview' => __DIR__ . '/..' . '/../lib/Sections/Admin/Overview.php',
...@@ -65,7 +60,12 @@ class ComposerStaticInitSettings ...@@ -65,7 +60,12 @@ class ComposerStaticInitSettings
'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => __DIR__ . '/..' . '/../lib/Sections/Personal/PersonalInfo.php', 'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => __DIR__ . '/..' . '/../lib/Sections/Personal/PersonalInfo.php',
'OCA\\Settings\\Sections\\Personal\\Security' => __DIR__ . '/..' . '/../lib/Sections/Personal/Security.php', 'OCA\\Settings\\Sections\\Personal\\Security' => __DIR__ . '/..' . '/../lib/Sections/Personal/Security.php',
'OCA\\Settings\\Sections\\Personal\\SyncClients' => __DIR__ . '/..' . '/../lib/Sections/Personal/SyncClients.php', 'OCA\\Settings\\Sections\\Personal\\SyncClients' => __DIR__ . '/..' . '/../lib/Sections/Personal/SyncClients.php',
'OCA\\Settings\\Settings\\Personal\\Additional' => __DIR__ . '/..' . '/../lib/Settings/Personal/Additional.php',
'OCA\\Settings\\Settings\\Personal\\PersonalInfo' => __DIR__ . '/..' . '/../lib/Settings/Personal/PersonalInfo.php',
'OCA\\Settings\\Settings\\Personal\\Security\\Authtokens' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/Authtokens.php',
'OCA\\Settings\\Settings\\Personal\\Security\\Password' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/Password.php',
'OCA\\Settings\\Settings\\Personal\\Security\\TwoFactor' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/TwoFactor.php', 'OCA\\Settings\\Settings\\Personal\\Security\\TwoFactor' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/TwoFactor.php',
'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => __DIR__ . '/..' . '/../lib/Settings/Personal/ServerDevNotice.php',
); );
public static function getInitializer(ClassLoader $loader) public static function getInitializer(ClassLoader $loader)
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
* *
*/ */
namespace OCA\Settings\Personal; namespace OCA\Settings\Settings\Personal;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
* *
*/ */
namespace OCA\Settings\Personal; namespace OCA\Settings\Settings\Personal;
use OC\Accounts\AccountManager; use OC\Accounts\AccountManager;
use OCA\FederatedFileSharing\AppInfo\Application; use OCA\FederatedFileSharing\AppInfo\Application;
......
...@@ -25,7 +25,7 @@ declare(strict_types=1); ...@@ -25,7 +25,7 @@ declare(strict_types=1);
* *
*/ */
namespace OCA\Settings\Personal\Security; namespace OCA\Settings\Settings\Personal\Security;
use OCP\IUserSession; use OCP\IUserSession;
use function array_map; use function array_map;
......
...@@ -26,7 +26,7 @@ declare(strict_types=1); ...@@ -26,7 +26,7 @@ declare(strict_types=1);
* *
*/ */
namespace OCA\Settings\Personal\Security; namespace OCA\Settings\Settings\Personal\Security;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\IUserManager; use OCP\IUserManager;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
* *
*/ */
namespace OCA\Settings\Personal; namespace OCA\Settings\Settings\Personal;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\Settings\ISettings; use OCP\Settings\ISettings;
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
namespace OCA\Settings\Tests\Controller; namespace OCA\Settings\Tests\Controller;
use OCA\Settings\Controller\AdminSettingsController; use OCA\Settings\Controller\AdminSettingsController;
use OCA\Settings\Personal\ServerDevNotice; use OCA\Settings\Settings\Personal\ServerDevNotice;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\Group\ISubAdmin; use OCP\Group\ISubAdmin;
use OCP\IGroupManager; use OCP\IGroupManager;
......
...@@ -29,8 +29,7 @@ namespace OCA\Settings\Tests\Settings\Personal\Security; ...@@ -29,8 +29,7 @@ namespace OCA\Settings\Tests\Settings\Personal\Security;
use OC\Authentication\Token\DefaultToken; use OC\Authentication\Token\DefaultToken;
use OC\Authentication\Token\IProvider as IAuthTokenProvider; use OC\Authentication\Token\IProvider as IAuthTokenProvider;
use OCA\Settings\Personal\Password; use OCA\Settings\Settings\Personal\Security\Authtokens;
use OCA\Settings\Personal\Security\Authtokens;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\IInitialStateService; use OCP\IInitialStateService;
use OCP\ISession; use OCP\ISession;
...@@ -55,7 +54,7 @@ class AuthtokensTest extends TestCase { ...@@ -55,7 +54,7 @@ class AuthtokensTest extends TestCase {
/** @var string */ /** @var string */
private $uid; private $uid;
/** @var Security\Authtokens */ /** @var Authtokens */
private $section; private $section;
protected function setUp(): void { protected function setUp(): void {
......
...@@ -25,9 +25,9 @@ declare(strict_types=1); ...@@ -25,9 +25,9 @@ declare(strict_types=1);
* *
*/ */
namespace OCA\Settings\Tests\Settings\Personal; namespace OCA\Settings\Tests\Settings\Personal\Security;
use OCA\Settings\Personal\Security\Password; use OCA\Settings\Settings\Personal\Security\Password;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\IUser; use OCP\IUser;
use OCP\IUserManager; use OCP\IUserManager;
...@@ -69,7 +69,7 @@ class PasswordTest extends TestCase { ...@@ -69,7 +69,7 @@ class PasswordTest extends TestCase {
$form = $this->section->getForm(); $form = $this->section->getForm();
$expected = new TemplateResponse('settings', 'settings/personal/security', [ $expected = new TemplateResponse('settings', 'settings/personal/security/password', [
'passwordChangeSupported' => true, 'passwordChangeSupported' => true,
]); ]);
$this->assertEquals($expected, $form); $this->assertEquals($expected, $form);
......
...@@ -175,7 +175,7 @@ class Manager implements IManager { ...@@ -175,7 +175,7 @@ class Manager implements IManager {
try { try {
/** @var ISettings $setting */ /** @var ISettings $setting */
$setting = \OC::$server->query($class); $setting = $this->container->query($class);
} catch (QueryException $e) { } catch (QueryException $e) {
$this->log->logException($e, ['level' => ILogger::INFO]); $this->log->logException($e, ['level' => ILogger::INFO]);
continue; continue;
...@@ -272,39 +272,6 @@ class Manager implements IManager { ...@@ -272,39 +272,6 @@ class Manager implements IManager {
return $forms; return $forms;
} }
/**
* @param string $section
*
* @return ISection[]
*/
private function getBuiltInPersonalSettings($section): array {
$forms = [];
if ($section === 'personal-info') {
/** @var ISettings $form */
$form = $this->container->query(\OCA\Settings\Personal\PersonalInfo::class);
$forms[$form->getPriority()] = [$form];
$form = new \OCA\Settings\Personal\ServerDevNotice();
$forms[$form->getPriority()] = [$form];
}
if ($section === 'security') {
/** @var ISettings $form */
$form = $this->container->query(\OCA\Settings\Personal\Security\Password::class);
$forms[$form->getPriority()] = [$form];
/** @var ISettings $form */
$form = $this->container->query(\OCA\Settings\Personal\Security\Authtokens::class);
$forms[$form->getPriority()] = [$form];
}
if ($section === 'additional') {
/** @var ISettings $form */
$form = $this->container->query(\OCA\Settings\Personal\Additional::class);
$forms[$form->getPriority()] = [$form];
}
return $forms;
}
/** /**
* @inheritdoc * @inheritdoc
*/ */
...@@ -380,7 +347,7 @@ class Manager implements IManager { ...@@ -380,7 +347,7 @@ class Manager implements IManager {
* @inheritdoc * @inheritdoc
*/ */
public function getPersonalSettings($section): array { public function getPersonalSettings($section): array {
$settings = $this->getBuiltInPersonalSettings($section); $settings = [];
$appSettings = $this->getSettings('personal', $section); $appSettings = $this->getSettings('personal', $section);
foreach ($appSettings as $setting) { foreach ($appSettings as $setting) {
......
...@@ -24,15 +24,14 @@ ...@@ -24,15 +24,14 @@
namespace OCA\Settings\Tests\AppInfo; namespace OCA\Settings\Tests\AppInfo;
use OC\Settings\Manager; use OC\Settings\Manager;
use OC\Settings\Section;
use OCA\Settings\Admin\Sharing; use OCA\Settings\Admin\Sharing;
use OCA\Settings\Personal\Password;
use OCP\IDBConnection; use OCP\IDBConnection;
use OCP\IL10N; use OCP\IL10N;
use OCP\ILogger; use OCP\ILogger;
use OCP\IServerContainer; use OCP\IServerContainer;
use OCP\IURLGenerator; use OCP\IURLGenerator;
use OCP\L10N\IFactory; use OCP\L10N\IFactory;
use OCP\Settings\ISettings;
use OCP\Settings\ISubAdminSettings; use OCP\Settings\ISubAdminSettings;
use Test\TestCase; use Test\TestCase;
...@@ -149,21 +148,27 @@ class ManagerTest extends TestCase { ...@@ -149,21 +148,27 @@ class ManagerTest extends TestCase {
} }
public function testGetPersonalSettings() { public function testGetPersonalSettings() {
$section = $this->createMock(Password::class); $section = $this->createMock(ISettings::class);
$section->expects($this->once()) $section->method('getPriority')
->method('getPriority')
->willReturn(16); ->willReturn(16);
$section2 = $this->createMock(Security\Authtokens::class); $section->method('getSection')
$section2->expects($this->once()) ->willReturn('security');
->method('getPriority') $section2 = $this->createMock(ISettings::class);
$section2->method('getPriority')
->willReturn(100); ->willReturn(100);
$section2->method('getSection')
->willReturn('security');
$this->manager->registerSetting('personal', 'section1');
$this->manager->registerSetting('personal', 'section2');
$this->container->expects($this->at(0)) $this->container->expects($this->at(0))
->method('query') ->method('query')
->with(Password::class) ->with('section1')
->willReturn($section); ->willReturn($section);
$this->container->expects($this->at(1)) $this->container->expects($this->at(1))
->method('query') ->method('query')
->with(Security\Authtokens::class) ->with('section2')
->willReturn($section2); ->willReturn($section2);
$settings = $this->manager->getPersonalSettings('security'); $settings = $this->manager->getPersonalSettings('security');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment