mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
N°3381 - finish integrating healthcheck status.php page
This commit is contained in:
@@ -15,12 +15,16 @@ use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class StatusTest extends ItopTestCase {
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function testStatusWrongUrl() {
|
||||
$sPath = __DIR__ . '/status_wrong.php';
|
||||
$sPath = APPROOT . '/status_wrong.php';
|
||||
|
||||
exec("php $sPath", $aOutput, $iRet);
|
||||
$this->assertNotEquals(0, $iRet, "Problem executing status page: $sPath, $iRet, aOutput:\n" . var_export($aOutput, true));
|
||||
@@ -31,7 +35,7 @@ class StatusTest extends ItopTestCase {
|
||||
*
|
||||
*/
|
||||
public function testStatusGood() {
|
||||
$sPath = __DIR__ . '/status.php';
|
||||
$sPath = APPROOT . '/webservices/status.php';
|
||||
|
||||
exec("php $sPath", $aOutput, $iRet);
|
||||
$this->assertEquals(0, $iRet, "Problem executing status page: $sPath, $iRet, aOutput:\n" . var_export($aOutput, true));
|
||||
@@ -41,10 +45,10 @@ class StatusTest extends ItopTestCase {
|
||||
*
|
||||
*/
|
||||
public function testStatusGoodWithJson() {
|
||||
$sPath = __DIR__ . '/status.php';
|
||||
$sPath = APPROOT . '/webservices/status.php';
|
||||
|
||||
exec("php $sPath", $aOutput, $iRet);
|
||||
$sAdditionnalInfo = "aOutput:\n" . var_export($aOutput, true);
|
||||
$sAdditionnalInfo = "aOutput:\n" . var_export($aOutput, true) . '.';
|
||||
|
||||
//Check response
|
||||
$this->assertNotEmpty($aOutput[0], 'Empty response. ' . $sAdditionnalInfo);
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
//Include status functions
|
||||
require_once(__DIR__.'/../../sources/application/status/status.inc.php');
|
||||
//Do check Status
|
||||
try
|
||||
{
|
||||
\Combodo\iTop\Application\Status\StatusStartup();
|
||||
$aResult = array('status' => STATUS_RUNNING, 'code' => \RestResult::OK, 'message' => '');
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$iCode = (defined('\RestResult::INTERNAL_ERROR')) ? \RestResult::INTERNAL_ERROR : 100;
|
||||
$aResult = array('status' => STATUS_ERROR, 'code' => $iCode, 'message' => $e->getMessage());
|
||||
http_response_code(500);
|
||||
}
|
||||
|
||||
//Set headers, based on webservices/rest.php
|
||||
$sContentType = 'application/json';
|
||||
header('Content-type: ' . $sContentType);
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
|
||||
//Output result
|
||||
$sResponse = json_encode($aResult);
|
||||
echo $sResponse;
|
||||
Reference in New Issue
Block a user