mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 02:28:44 +02:00
N°5120 - Unattended install : use cty toolkit version (#624)
* N°5120 - Unattended install : use cty toolkit version * N°5120 - CLI mode validation * 5120 - bring CI enhancements * 5120 - bring back saas use-itop-config option: to read db settings from conf directly * 5120 - move unattended script in setup folder/unattended-install * 5120 - use-itop-config option: take db_tls_enabled and db_tls_ca into account * 5120 - move test * 5120 - put ci enhancements back - logs and conf preservation with install mode * 5120 - keep PR simple - remove saas use-itop-config option for now * 5120 - remove ci enhancement to preserve configuration * Update setup/unattended-install/README.md Co-authored-by: Thomas Casteleyn <thomas.casteleyn@super-visions.com> * 5120 - documentation * 5120 - fix log level * 5120 - fix test * fix phpunit test comment --------- Co-authored-by: Thomas Casteleyn <thomas.casteleyn@super-visions.com>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Setup\UnattendedInstall;
|
||||
|
||||
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
|
||||
class UnattendedInstallTest extends ItopDataTestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
$aFiles = [
|
||||
'web.config',
|
||||
'.htaccess',
|
||||
];
|
||||
foreach ($aFiles as $sFile){
|
||||
$sPath = APPROOT."setup/unattended-install/$sFile";
|
||||
if (is_file("$sPath.back")){
|
||||
rename("$sPath.back", $sPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function callUnattendedFromHttp() : string {
|
||||
$ch = curl_init();
|
||||
|
||||
$sUrl = \MetaModel::GetConfig()->Get('app_root_url');
|
||||
curl_setopt($ch, CURLOPT_URL, "$sUrl/setup/unattended-install/unattended-install.php");
|
||||
curl_setopt($ch, CURLOPT_POST, 1);// set post data to true
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, []);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
// Force disable of certificate check as most of dev / test env have a self-signed certificate
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
|
||||
$sJson = curl_exec($ch);
|
||||
curl_close ($ch);
|
||||
return $sJson;
|
||||
}
|
||||
public function testCallUnattendedInstallFromHttp(){
|
||||
$sJson = $this->callUnattendedFromHttp();
|
||||
if (false !== strpos($sJson, "403 Forbidden")){
|
||||
//.htaccess / webconfig effect
|
||||
$aFiles = [
|
||||
'web.config',
|
||||
'.htaccess',
|
||||
];
|
||||
foreach ($aFiles as $sFile){
|
||||
$sPath = APPROOT."setup/unattended-install/$sFile";
|
||||
if (is_file("$sPath")) {
|
||||
rename($sPath, "$sPath.back");
|
||||
}
|
||||
}
|
||||
|
||||
$sJson = $this->callUnattendedFromHttp();
|
||||
}
|
||||
|
||||
$this->assertEquals("Mode CLI only", $sJson, "even without HTTP protection, script should NOT be called directly by HTTP");
|
||||
}
|
||||
|
||||
public function testCallUnattendedInstallFromCLI() {
|
||||
$cliPath = realpath(APPROOT."/setup/unattended-install/unattended-install.php");
|
||||
$res = exec("php ".$cliPath);
|
||||
|
||||
$this->assertEquals("Param file `default-params.xml` doesn't exist ! Exiting...", $res);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user