Merge pull request #57737 from nextcloud/feat/add-twofactor-to-presets
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Integration sqlite / changes (push) Waiting to run
Integration sqlite / integration-sqlite (master, 8.4, main, --tags ~@large files_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, capabilities_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, collaboration_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, comments_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, dav_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, federation_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, file_conversions) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, files_reminders) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, filesdrop_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, ldap_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, openldap_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, openldap_numerical_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, remoteapi_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, routing_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, setup_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, sharees_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, sharing_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, theming_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, videoverification_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite-summary (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis (push) Waiting to run
Psalm static code analysis / static-code-analysis-security (push) Waiting to run
Psalm static code analysis / static-code-analysis-ocp (push) Waiting to run
Psalm static code analysis / static-code-analysis-ncu (push) Waiting to run
Psalm static code analysis / static-code-analysis-strict (push) Waiting to run

feat: Add twofactor applications to most of the presets
This commit is contained in:
Côme Chilliet 2026-02-02 15:12:08 +01:00 committed by GitHub
commit 550b15a19a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 31 deletions

View file

@ -233,8 +233,22 @@ class PresetManager {
*/
private function getPresetApps(Preset $preset): array {
return match ($preset) {
Preset::CLUB, Preset::FAMILY, Preset::SCHOOL, Preset::UNIVERSITY, Preset::SMALL, Preset::MEDIUM, Preset::LARGE => ['enabled' => ['user_status', 'guests'], 'disabled' => []],
Preset::SHARED => ['enabled' => ['external'], 'disabled' => ['user_status']],
Preset::CLUB, Preset::FAMILY, Preset::SCHOOL, Preset::SMALL, Preset::MEDIUM
=> [
'enabled' => ['user_status','guests','twofactor_backupcodes','twofactor_totp','twofactor_webauthn'],
'disabled' => []],
Preset::UNIVERSITY, Preset::LARGE
=> [
'enabled' => ['user_status','guests'],
'disabled' => []],
Preset::SHARED
=> [
'enabled' => ['external','twofactor_backupcodes','twofactor_totp','twofactor_webauthn'],
'disabled' => ['user_status']],
Preset::PRIVATE
=> [
'enabled' => ['twofactor_backupcodes','twofactor_totp','twofactor_webauthn'],
'disabled' => []],
default => ['enabled' => [], 'disabled' => []],
};
}

View file

@ -51,7 +51,7 @@ class AppConfigTest extends TestCase {
protected function getAppConfig($cached = false): AppConfig {
$this->config->method('getSystemValueBool')
->with('cache_app_config', $cached)
->with('cache_app_config', true)
->willReturn(true);
$this->cacheFactory->method('isLocalCacheAvailable')->willReturn($cached);
if ($cached) {

View file

@ -10,12 +10,10 @@ namespace Tests\lib\Config;
use OC\AppConfig;
use OC\AppFramework\Bootstrap\Coordinator;
use OC\Config\ConfigManager;
use OC\Config\PresetManager;
use OCP\App\IAppManager;
use OCP\Config\Exceptions\TypeConflictException;
use OCP\Config\Exceptions\UnknownKeyException;
use OCP\Config\IUserConfig;
use OCP\Config\Lexicon\Preset;
use OCP\Exceptions\AppConfigTypeConflictException;
use OCP\Exceptions\AppConfigUnknownKeyException;
use OCP\IAppConfig;
@ -34,7 +32,6 @@ class LexiconTest extends TestCase {
private IAppConfig $appConfig;
private IUserConfig $userConfig;
private ConfigManager $configManager;
private PresetManager $presetManager;
private IAppManager $appManager;
protected function setUp(): void {
@ -49,7 +46,6 @@ class LexiconTest extends TestCase {
$this->appConfig = Server::get(IAppConfig::class);
$this->userConfig = Server::get(IUserConfig::class);
$this->configManager = Server::get(ConfigManager::class);
$this->presetManager = Server::get(PresetManager::class);
$this->appManager = Server::get(IAppManager::class);
}
@ -215,30 +211,6 @@ class LexiconTest extends TestCase {
$this->assertSame(false, $this->appConfig->getValueBool(TestConfigLexicon_I::APPID, 'key4'));
}
public function testAppConfigLexiconPreset() {
$this->presetManager->setLexiconPreset(Preset::FAMILY);
$this->assertSame('family', $this->appConfig->getValueString(TestLexicon_E::APPID, 'key3'));
}
public function testAppConfigLexiconPresets() {
$this->presetManager->setLexiconPreset(Preset::MEDIUM);
$this->assertSame('club+medium', $this->appConfig->getValueString(TestLexicon_E::APPID, 'key3'));
$this->presetManager->setLexiconPreset(Preset::FAMILY);
$this->assertSame('family', $this->appConfig->getValueString(TestLexicon_E::APPID, 'key3'));
}
public function testUserConfigLexiconPreset() {
$this->presetManager->setLexiconPreset(Preset::FAMILY);
$this->assertSame('family', $this->userConfig->getValueString('user1', TestLexicon_E::APPID, 'key3'));
}
public function testUserConfigLexiconPresets() {
$this->presetManager->setLexiconPreset(Preset::MEDIUM);
$this->assertSame('club+medium', $this->userConfig->getValueString('user1', TestLexicon_E::APPID, 'key3'));
$this->presetManager->setLexiconPreset(Preset::FAMILY);
$this->assertSame('family', $this->userConfig->getValueString('user1', TestLexicon_E::APPID, 'key3'));
}
public function testLexiconIndexedUpdate() {
$this->userConfig->setValueString('user1', TestLexicon_UserIndexed::APPID, 'key1', 'abcd');
$this->userConfig->setValueString('user2', TestLexicon_UserIndexed::APPID, 'key1', '1234', flags: 64);