mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-20 09:08:42 +02:00
Merge branch 'support/3.0' into support/3.1
# Conflicts: # setup/modulediscovery.class.inc.php # setup/runtimeenv.class.inc.php # setup/unattended-install/unattended-install.php # tests/setup_params/default-params.xml
This commit is contained in:
@@ -5,7 +5,7 @@ php_version=8.2-apache
|
||||
db_version=5.7
|
||||
|
||||
[itop]
|
||||
itop_setup=tests/setup_params/default-params.xml
|
||||
;itop_setup=tests/setup_params/default-params.xml
|
||||
itop_backup=tests/backups/backup-itop.tar.gz
|
||||
|
||||
[phpunit]
|
||||
|
||||
@@ -0,0 +1,315 @@
|
||||
<?php
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Setup\UnattendedInstall;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class InstallationFileServiceTest extends TestCase {
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
require_once(dirname(__FILE__, 6) . '/setup/unattended-install/InstallationFileService.php');
|
||||
$this->sFolderToCleanup = null;
|
||||
\ModuleDiscovery::ResetCache();
|
||||
}
|
||||
|
||||
protected function tearDown(): void {
|
||||
parent::tearDown();
|
||||
|
||||
$sModuleId = "itop-problem-mgmt";
|
||||
$this->RecurseMoveDir(APPROOT."data/production-modules/$sModuleId", APPROOT . "datamodels/2.x/$sModuleId");
|
||||
}
|
||||
|
||||
public function GetDefaultModulesProvider() {
|
||||
return [
|
||||
'all checked' => [ true ],
|
||||
'only defaut + mandatory' => [ false ],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider GetDefaultModulesProvider
|
||||
*/
|
||||
public function testProcessInstallationChoices($bInstallationOptionalChoicesChecked=false) {
|
||||
$sPath = realpath(dirname(__FILE__, 6)."/datamodels/2.x/installation.xml");
|
||||
$this->assertTrue(is_file($sPath));
|
||||
$oInstallationFileService = new \InstallationFileService($sPath, 'production', [], $bInstallationOptionalChoicesChecked);
|
||||
$oInstallationFileService->ProcessInstallationChoices();
|
||||
$aExpectedModules = [
|
||||
"itop-config-mgmt",
|
||||
"itop-attachments",
|
||||
"itop-profiles-itil",
|
||||
"itop-welcome-itil",
|
||||
"itop-tickets",
|
||||
"itop-files-information",
|
||||
"combodo-db-tools",
|
||||
"itop-core-update",
|
||||
"itop-hub-connector",
|
||||
"itop-oauth-client",
|
||||
"itop-datacenter-mgmt",
|
||||
"itop-endusers-devices",
|
||||
"itop-storage-mgmt",
|
||||
"itop-virtualization-mgmt",
|
||||
"itop-service-mgmt",
|
||||
"itop-request-mgmt",
|
||||
"itop-portal",
|
||||
"itop-portal-base",
|
||||
"itop-change-mgmt",
|
||||
];
|
||||
|
||||
$aExpectedUnselectedModules = [
|
||||
'itop-change-mgmt-itil',
|
||||
'itop-incident-mgmt-itil',
|
||||
'itop-request-mgmt-itil',
|
||||
'itop-service-mgmt-provider',
|
||||
];
|
||||
|
||||
if ($bInstallationOptionalChoicesChecked){
|
||||
$aExpectedModules []= "itop-problem-mgmt";
|
||||
$aExpectedModules []= "itop-knownerror-mgmt";
|
||||
} else {
|
||||
$aExpectedUnselectedModules []= "itop-problem-mgmt";
|
||||
$aExpectedUnselectedModules []= "itop-knownerror-mgmt";
|
||||
}
|
||||
|
||||
sort($aExpectedModules);
|
||||
$aModules = array_keys($oInstallationFileService->GetSelectedModules());
|
||||
sort($aModules);
|
||||
|
||||
$this->assertEquals($aExpectedModules, $aModules);
|
||||
|
||||
$aUnselectedModules = array_keys($oInstallationFileService->GetUnSelectedModules());
|
||||
sort($aExpectedUnselectedModules);
|
||||
sort($aUnselectedModules);
|
||||
$this->assertEquals($aExpectedUnselectedModules, $aUnselectedModules);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider GetDefaultModulesProvider
|
||||
*/
|
||||
public function testGetAllSelectedModules($bInstallationOptionalChoicesChecked=false) {
|
||||
$sPath = realpath(dirname(__FILE__, 6)."/datamodels/2.x/installation.xml");
|
||||
$oInstallationFileService = new \InstallationFileService($sPath, 'production', [], $bInstallationOptionalChoicesChecked);
|
||||
$oInstallationFileService->Init();
|
||||
|
||||
$aSelectedModules = $oInstallationFileService->GetSelectedModules();
|
||||
$aExpectedInstallationModules = [
|
||||
"itop-config-mgmt",
|
||||
"itop-attachments",
|
||||
"itop-profiles-itil",
|
||||
"itop-welcome-itil",
|
||||
"itop-tickets",
|
||||
"itop-files-information",
|
||||
"combodo-db-tools",
|
||||
"itop-core-update",
|
||||
"itop-hub-connector",
|
||||
"itop-oauth-client",
|
||||
"itop-datacenter-mgmt",
|
||||
"itop-endusers-devices",
|
||||
"itop-storage-mgmt",
|
||||
"itop-virtualization-mgmt",
|
||||
"itop-service-mgmt",
|
||||
"itop-request-mgmt",
|
||||
"itop-portal",
|
||||
"itop-portal-base",
|
||||
"itop-change-mgmt",
|
||||
];
|
||||
if ($bInstallationOptionalChoicesChecked){
|
||||
$aExpectedInstallationModules []= "itop-problem-mgmt";
|
||||
$aExpectedInstallationModules []= "itop-knownerror-mgmt";
|
||||
}
|
||||
|
||||
$aExpectedAuthenticationModules = [
|
||||
'authent-cas',
|
||||
'authent-external',
|
||||
'authent-ldap',
|
||||
'authent-local',
|
||||
];
|
||||
|
||||
$aUnvisibleModules = [
|
||||
'itop-backup',
|
||||
'itop-config',
|
||||
'itop-sla-computation',
|
||||
];
|
||||
|
||||
$aAutoSelectedModules = [
|
||||
'itop-bridge-virtualization-storage',
|
||||
];
|
||||
|
||||
$this->checkModuleList("installation.xml choices", $aExpectedInstallationModules, $aSelectedModules);
|
||||
$this->checkModuleList("authentication category", $aExpectedAuthenticationModules, $aSelectedModules);
|
||||
$this->checkModuleList("unvisible", $aUnvisibleModules, $aSelectedModules);
|
||||
$this->checkModuleList("auto-select", $aAutoSelectedModules, $aSelectedModules);
|
||||
$this->assertEquals([], $aSelectedModules, "there should be no more modules remaining apart from below lists");
|
||||
}
|
||||
|
||||
private function GetSelectedItilExtensions(bool $coreExtensionIncluded, bool $bKnownMgtIncluded) : array {
|
||||
$aExtensions = [
|
||||
'itop-config-mgmt-datacenter',
|
||||
'itop-config-mgmt-end-user',
|
||||
'itop-config-mgmt-storage',
|
||||
'itop-config-mgmt-virtualization',
|
||||
'itop-service-mgmt-enterprise',
|
||||
'itop-ticket-mgmt-itil',
|
||||
'itop-ticket-mgmt-itil-user-request',
|
||||
'itop-ticket-mgmt-itil-incident',
|
||||
'itop-ticket-mgmt-itil-enhanced-portal',
|
||||
'itop-change-mgmt-itil',
|
||||
];
|
||||
|
||||
if ($coreExtensionIncluded){
|
||||
$aExtensions[]= 'itop-config-mgmt-core';
|
||||
}
|
||||
|
||||
if ($bKnownMgtIncluded){
|
||||
$aExtensions[]= 'itop-kown-error-mgmt';
|
||||
}
|
||||
|
||||
return $aExtensions;
|
||||
|
||||
}
|
||||
|
||||
public function ItilExtensionProvider() {
|
||||
return [
|
||||
'all itil extensions + INCLUDING known-error-mgt' => [
|
||||
'aSelectedExtensions' => $this->GetSelectedItilExtensions(true, true),
|
||||
'bKnownMgtSelected' => true,
|
||||
],
|
||||
'all itil extensions WITHOUT known-error-mgt' => [
|
||||
'aSelectedExtensions' => $this->GetSelectedItilExtensions(true, false),
|
||||
'bKnownMgtSelected' => false,
|
||||
],
|
||||
'all itil extensions WITHOUT core mandatory ones + INCLUDING known-error-mgt' => [
|
||||
'aSelectedExtensions' => $this->GetSelectedItilExtensions(false, true),
|
||||
'bKnownMgtSelected' => true,
|
||||
],
|
||||
'all itil extensions WITHOUT core mandatory ones and WITHOUT known-error-mgt' => [
|
||||
'aSelectedExtensions' => $this->GetSelectedItilExtensions(false, false),
|
||||
'bKnownMgtSelected' => false,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ItilExtensionProvider
|
||||
*/
|
||||
public function testGetAllSelectedModules_withItilExtensions(array $aSelectedExtensions, bool $bKnownMgtSelected) {
|
||||
$sPath = realpath(dirname(__FILE__, 6)."/datamodels/2.x/installation.xml");
|
||||
$oInstallationFileService = new \InstallationFileService($sPath, 'production', $aSelectedExtensions);
|
||||
$oInstallationFileService->Init();
|
||||
|
||||
$aSelectedModules = $oInstallationFileService->GetSelectedModules();
|
||||
$aExpectedInstallationModules = [
|
||||
"itop-config-mgmt",
|
||||
"itop-attachments",
|
||||
"itop-profiles-itil",
|
||||
"itop-welcome-itil",
|
||||
"itop-tickets",
|
||||
"itop-files-information",
|
||||
"combodo-db-tools",
|
||||
"itop-core-update",
|
||||
"itop-hub-connector",
|
||||
"itop-oauth-client",
|
||||
"itop-datacenter-mgmt",
|
||||
"itop-endusers-devices",
|
||||
"itop-storage-mgmt",
|
||||
"itop-virtualization-mgmt",
|
||||
"itop-service-mgmt",
|
||||
"itop-request-mgmt-itil",
|
||||
"itop-incident-mgmt-itil",
|
||||
"itop-portal",
|
||||
"itop-portal-base",
|
||||
"itop-change-mgmt-itil",
|
||||
"itop-full-itil",
|
||||
];
|
||||
if ($bKnownMgtSelected){
|
||||
$aExpectedInstallationModules []= "itop-knownerror-mgmt";
|
||||
}
|
||||
|
||||
$aExpectedAuthenticationModules = [
|
||||
'authent-cas',
|
||||
'authent-external',
|
||||
'authent-ldap',
|
||||
'authent-local',
|
||||
];
|
||||
|
||||
$aUnvisibleModules = [
|
||||
'itop-backup',
|
||||
'itop-config',
|
||||
'itop-sla-computation',
|
||||
];
|
||||
|
||||
$aAutoSelectedModules = [
|
||||
'itop-bridge-virtualization-storage',
|
||||
];
|
||||
|
||||
$this->checkModuleList("installation.xml choices", $aExpectedInstallationModules, $aSelectedModules);
|
||||
$this->checkModuleList("authentication category", $aExpectedAuthenticationModules, $aSelectedModules);
|
||||
$this->checkModuleList("unvisible", $aUnvisibleModules, $aSelectedModules);
|
||||
$this->checkModuleList("auto-select", $aAutoSelectedModules, $aSelectedModules);
|
||||
$this->assertEquals([], $aSelectedModules, "there should be no more modules remaining apart from below lists");
|
||||
}
|
||||
|
||||
private function checkModuleList(string $sModuleCategory, array $aExpectedModuleList, array &$aSelectedModules) {
|
||||
$aMissingModules = [];
|
||||
|
||||
foreach ($aExpectedModuleList as $sModuleId){
|
||||
if (! array_key_exists($sModuleId, $aSelectedModules)){
|
||||
$aMissingModules[]=$sModuleId;
|
||||
} else {
|
||||
unset($aSelectedModules[$sModuleId]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertEquals([], $aMissingModules, "$sModuleCategory modules are missing");
|
||||
|
||||
}
|
||||
|
||||
public function ProductionModulesProvider() {
|
||||
return [
|
||||
'module autoload as located in production-modules' => [ true ],
|
||||
'module not loaded' => [ false ],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ProductionModulesProvider
|
||||
*/
|
||||
public function testGetAllSelectedModules_ProductionModules(bool $bModuleInProductionModulesFolder) {
|
||||
$sModuleId = "itop-problem-mgmt";
|
||||
if ($bModuleInProductionModulesFolder){
|
||||
if (! is_dir(APPROOT."data/production-modules")){
|
||||
@mkdir(APPROOT."data/production-modules");
|
||||
}
|
||||
|
||||
$this->RecurseMoveDir(APPROOT . "datamodels/2.x/$sModuleId", APPROOT."data/production-modules/$sModuleId");
|
||||
}
|
||||
|
||||
$sPath = realpath(dirname(__FILE__, 6)."/datamodels/2.x/installation.xml");
|
||||
$oInstallationFileService = new \InstallationFileService($sPath, 'production', [], false);
|
||||
$oInstallationFileService->Init();
|
||||
|
||||
$aSelectedModules = $oInstallationFileService->GetSelectedModules();
|
||||
$this->assertEquals($bModuleInProductionModulesFolder, array_key_exists($sModuleId, $aSelectedModules));
|
||||
}
|
||||
|
||||
private function RecurseMoveDir($sFromDir, $sToDir) {
|
||||
if (! is_dir($sFromDir)){
|
||||
return;
|
||||
}
|
||||
|
||||
if (! is_dir($sToDir)){
|
||||
@mkdir($sToDir);
|
||||
}
|
||||
|
||||
foreach (glob("$sFromDir/*") as $sPath){
|
||||
$sToPath = $sToDir.'/'.basename($sPath);
|
||||
if (is_file($sPath)){
|
||||
@rename($sPath, $sToPath);
|
||||
} else {
|
||||
$this->RecurseMoveDir($sPath, $sToPath);
|
||||
}
|
||||
}
|
||||
|
||||
@rmdir($sFromDir);
|
||||
}
|
||||
}
|
||||
@@ -63,9 +63,12 @@ class UnattendedInstallTest extends ItopDataTestCase
|
||||
}
|
||||
|
||||
public function testCallUnattendedInstallFromCLI() {
|
||||
$cliPath = realpath(APPROOT."/setup/unattended-install/unattended-install.php");
|
||||
$res = exec("php ".$cliPath);
|
||||
$sCliPath = realpath(APPROOT."/setup/unattended-install/unattended-install.php");
|
||||
exec(sprintf("%s %s", PHP_BINARY, $sCliPath), $aOutput, $iCode);
|
||||
|
||||
$this->assertEquals("Param file `default-params.xml` doesn't exist ! Exiting...", $res);
|
||||
$sOutput = implode('\n', $aOutput);
|
||||
var_dump($sOutput);
|
||||
$this->assertStringContainsString("Missing mandatory argument `--param-file`", $sOutput);
|
||||
$this->assertEquals(255, $iCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,82 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<installation>
|
||||
<!-- On manual installs, this file is generated in setup/install-*.xml -->
|
||||
<mode>install</mode>
|
||||
<preinstall>
|
||||
<copies type="array"/>
|
||||
</preinstall>
|
||||
<source_dir>datamodels/2.x/</source_dir>
|
||||
<datamodel_version>2.5.0</datamodel_version>
|
||||
<previous_configuration_file>default-config-itop.php</previous_configuration_file>
|
||||
<extensions_dir>extensions</extensions_dir>
|
||||
<target_env>production</target_env>
|
||||
<workspace_dir></workspace_dir>
|
||||
<database>
|
||||
<server></server>
|
||||
<user>jenkins_itop</user>
|
||||
<pwd>IKnowYouSeeMeInJenkinsConf</pwd>
|
||||
<name>itop_ci</name>
|
||||
<db_tls_enabled></db_tls_enabled>
|
||||
<db_tls_ca></db_tls_ca>
|
||||
<prefix></prefix>
|
||||
</database>
|
||||
<url>http://localhost/iTop/</url>
|
||||
<graphviz_path>/usr/bin/dot</graphviz_path>
|
||||
<admin_account>
|
||||
<user>admin</user>
|
||||
<pwd>admin</pwd>
|
||||
<language>EN US</language>
|
||||
</admin_account>
|
||||
<language>EN US</language>
|
||||
<selected_modules type="array">
|
||||
<item>authent-cas</item>
|
||||
<item>authent-external</item>
|
||||
<item>authent-ldap</item>
|
||||
<item>authent-local</item>
|
||||
<item>itop-backup</item>
|
||||
<item>itop-config</item>
|
||||
<item>itop-files-information</item>
|
||||
<item>itop-portal-base</item>
|
||||
<item>itop-profiles-itil</item>
|
||||
<item>itop-sla-computation</item>
|
||||
<item>itop-welcome-itil</item>
|
||||
<item>itop-structure</item>
|
||||
<item>itop-config-mgmt</item>
|
||||
<item>itop-attachments</item>
|
||||
<item>itop-tickets</item>
|
||||
<item>combodo-db-tools</item>
|
||||
<item>itop-core-update</item>
|
||||
<item>itop-hub-connector</item>
|
||||
<item>itop-datacenter-mgmt</item>
|
||||
<item>itop-endusers-devices</item>
|
||||
<item>itop-storage-mgmt</item>
|
||||
<item>itop-virtualization-mgmt</item>
|
||||
<item>itop-bridge-virtualization-storage</item>
|
||||
<item>itop-service-mgmt</item>
|
||||
<item>itop-bridge-cmdb-ticket</item>
|
||||
<item>itop-bridge-cmdb-services</item>
|
||||
<item>itop-request-mgmt</item>
|
||||
<item>itop-portal</item>
|
||||
<item>itop-change-mgmt</item>
|
||||
<item>itop-knownerror-mgmt</item>
|
||||
<item>itop-faq-light</item>
|
||||
</selected_modules>
|
||||
<selected_extensions type="array">
|
||||
<item>itop-config-mgmt-core</item>
|
||||
<item>itop-config-mgmt-datacenter</item>
|
||||
<item>itop-config-mgmt-end-user</item>
|
||||
<item>itop-config-mgmt-storage</item>
|
||||
<item>itop-config-mgmt-virtualization</item>
|
||||
<item>itop-service-mgmt-enterprise</item>
|
||||
<item>itop-ticket-mgmt-simple-ticket</item>
|
||||
<item>itop-ticket-mgmt-simple-ticket-enhanced-portal</item>
|
||||
<item>itop-change-mgmt-simple</item>
|
||||
<item>itop-kown-error-mgmt</item>
|
||||
</selected_extensions>
|
||||
<sample_data>1</sample_data>
|
||||
<old_addon></old_addon>
|
||||
<options>
|
||||
<generate_config>1</generate_config>
|
||||
</options>
|
||||
<mysql_bindir></mysql_bindir>
|
||||
<!-- On manual installs, this file is generated in setup/install-*.xml -->
|
||||
<mode>install</mode>
|
||||
<preinstall>
|
||||
<copies type="array"/>
|
||||
</preinstall>
|
||||
<source_dir>datamodels/2.x/</source_dir>
|
||||
<datamodel_version>2.5.0</datamodel_version>
|
||||
<previous_configuration_file>default-config-itop.php</previous_configuration_file>
|
||||
<extensions_dir>extensions</extensions_dir>
|
||||
<target_env>production</target_env>
|
||||
<workspace_dir></workspace_dir>
|
||||
<database>
|
||||
<server></server>
|
||||
<user>jenkins_itop</user>
|
||||
<pwd>IKnowYouSeeMeInJenkinsConf</pwd>
|
||||
<name>itop_ci</name>
|
||||
<db_tls_enabled></db_tls_enabled>
|
||||
<db_tls_ca></db_tls_ca>
|
||||
<prefix></prefix>
|
||||
</database>
|
||||
<url>http://localhost/iTop/</url>
|
||||
<graphviz_path>/usr/bin/dot</graphviz_path>
|
||||
<admin_account>
|
||||
<user>admin</user>
|
||||
<pwd>admin</pwd>
|
||||
<language>EN US</language>
|
||||
</admin_account>
|
||||
<language>EN US</language>
|
||||
<selected_modules type="array">
|
||||
</selected_modules>
|
||||
<selected_extensions type="array">
|
||||
</selected_extensions>
|
||||
<sample_data>1</sample_data>
|
||||
<old_addon></old_addon>
|
||||
<options>
|
||||
<generate_config>1</generate_config>
|
||||
</options>
|
||||
<mysql_bindir></mysql_bindir>
|
||||
</installation>
|
||||
|
||||
Reference in New Issue
Block a user