N°3381 - finish integrating healthcheck status.php page

This commit is contained in:
odain
2020-10-19 11:42:48 +02:00
parent 6edb308480
commit e7360661be
2 changed files with 10 additions and 6 deletions

View File

@@ -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);

View File

@@ -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;