Compare commits

...

3 Commits

Author SHA1 Message Date
Benjamin DALSASS
078ef74cf0 N°9728 - Improve config editor
- fix unitary tests
2026-11-19 09:41:04 +01:00
Benjamin DALSASS
a9c6a8073d N°9728 - Improve config editor
- add unitary tests
2026-11-18 10:10:30 +01:00
Benjamin DALSASS
02b48c8ca8 N°9728 - Improve config editor 2026-11-10 11:15:12 +01:00
2 changed files with 1220 additions and 1124 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -91,4 +91,94 @@ class ConfigTest extends ItopTestCase
],
];
}
/**
* @dataProvider ProviderModuleSettingsRoundTrip
*
* @param array<string, array<string, mixed>> $aModuleSettings
*
* @since 3.2.4 3.3.1 3.4.0 N°9728
*/
public function testWriteToFilePreservesModuleSettings(array $aModuleSettings): void
{
$sTmpFile = $this->GetTemporaryFilePath('config-module-settings-');
$oConfig = new Config();
foreach ($aModuleSettings as $sModule => $aProperties) {
foreach ($aProperties as $sProperty => $value) {
$oConfig->SetModuleSetting($sModule, $sProperty, $value);
}
}
$this->assertTrue($oConfig->WriteToFile($sTmpFile));
$oReloadedConfig = new Config($sTmpFile);
$this->assertSame($aModuleSettings, $oReloadedConfig->ToArray()['module_settings']);
$oReloadedConfig->Set('app_root_url', 'https://itop.example.invalid/');
$this->assertTrue($oReloadedConfig->WriteToFile());
$oSavedConfig = new Config($sTmpFile);
$this->assertSame($aModuleSettings, $oSavedConfig->ToArray()['module_settings']);
$this->assertSame('https://itop.example.invalid/', $oSavedConfig->Get('app_root_url'));
}
/**
* @return array<string, array{array<string, array<string, mixed>>}>
*
* @since 3.2.4 3.3.1 3.4.0 N°9728
*/
public function ProviderModuleSettingsRoundTrip(): array
{
$aModuleSettings = [
'authent-cas' => [
'cas_debug' => false,
'cas_host' => 'sso.example.invalid',
'cas_port' => 443,
'cas_context' => '/cas',
'cas_version' => '3.0',
'service_base_url' => 'https://itop.example.invalid/',
],
'authent-ldap' => [
'host' => 'ldap.example.invalid',
'port' => 389,
'default_user' => '',
'default_pwd' => '',
'base_dn' => 'ou=people,dc=example,dc=invalid',
'user_query' => '(uid=%1$s)',
'options' => [17 => 3, 8 => 0],
'start_tls' => true,
'debug' => false,
'servers' => [],
],
'itop-attachments' => [
'allowed_classes' => ['Ticket', 'Contact', 'FunctionalCI'],
'position' => 'relations',
'preview_max_width' => 600,
'icon_preview_max_size' => 0,
],
'itop-backup' => [
'mysql_bindir' => '/usr/bin/',
'week_days' => '1,2,3,4,5',
'time' => '02:30',
'retention_count' => 7,
'enabled' => true,
'itop_backup_incident' => null,
],
'itop-log-mgmt' => [
'browser_white_list' => ['/Firefox\\/[0-9.]+/', '/Chrome\\/[0-9.]+/'],
'browser_only' => false,
],
];
$aCases = [];
foreach ($aModuleSettings as $sModule => $aProperties) {
$aCases[$sModule] = [[$sModule => $aProperties]];
}
$aCases['all modules'] = [$aModuleSettings];
$aCases['apostrophe in module name'] = [["customer's-module" => ['enabled' => true]]];
$aCases['apostrophe in property name'] = [['itop-backup' => ["customer's_path" => '/var/backups/']]];
$aCases['trailing backslash in module name'] = [['custom-module\\' => ['enabled' => false]]];
$aCases['backslash before apostrophe in property name'] = [['itop-backup' => ["customer\\'s_path" => 'C:\\Backups\\']]];
$aCases['spaces and double quotes in keys'] = [['custom module' => ['display "label"' => 'Backup status']]];
return $aCases;
}
}