Skip to content
Snippets Groups Projects
Verified Commit 586e672c authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT unit test for renderJNLP

parent 9e49c558
No related branches found
No related tags found
No related merge requests found
<?php
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
* @brief ActionsControllerTest
* @author dev <dev@maarch.org>
* @ingroup core
*/
use PHPUnit\Framework\TestCase;
class CoreControllerTest extends TestCase
{
public function testInitialize()
{
$coreController = new \SrcCore\controllers\CoreController();
$environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']);
$request = \Slim\Http\Request::createFromEnvironment($environment);
$response = $coreController->getAdministration($request, new \Slim\Http\Response());
$responseBody = json_decode((string)$response->getBody());
$this->assertNotEmpty($responseBody->administrations->organisation);
$this->assertNotEmpty($responseBody->administrations->classement);
$this->assertNotEmpty($responseBody->administrations->production);
$this->assertNotEmpty($responseBody->administrations->supervision);
}
public function testrenderJnlp()
{
// ERROR FILE NAME
$coreController = new \SrcCore\controllers\CoreController();
$environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']);
$request = \Slim\Http\Request::createFromEnvironment($environment);
$aArgs = [
'fileName' => 'superadmin_maarch_12345.jnlp'
];
$fullRequest = $request->withQueryParams($aArgs);
$response = $coreController->renderJnlp($fullRequest, new \Slim\Http\Response());
$responseBody = json_decode((string)$response->getBody());
$this->assertSame('File name forbidden', $responseBody->errors);
// ERROR EXTENSION
$request = \Slim\Http\Request::createFromEnvironment($environment);
$aArgs = [
'fileName' => 'superadmin_maarchCM_12345.js'
];
$fullRequest = $request->withQueryParams($aArgs);
$response = $coreController->renderJnlp($fullRequest, new \Slim\Http\Response());
$responseBody = json_decode((string)$response->getBody());
$this->assertSame('File extension forbidden', $responseBody->errors);
}
}
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
<file>core/Test/StatusControllerTest.php</file> <file>core/Test/StatusControllerTest.php</file>
<file>core/Test/UserControllerTest.php</file> <file>core/Test/UserControllerTest.php</file>
<file>core/Test/VersionUpdateControllerTest.php</file> <file>core/Test/VersionUpdateControllerTest.php</file>
<file>core/Test/CoreControllerTest.php</file>
<!--<file>modules/convert/Test/ProcessConvertTest.php</file>--> <!--<file>modules/convert/Test/ProcessConvertTest.php</file>-->
<!--<file>modules/convert/Test/ProcessFulltextTest.php</file>--> <!--<file>modules/convert/Test/ProcessFulltextTest.php</file>-->
<!--<file>modules/convert/Test/ProcessManageConvertTest.php</file>--> <!--<file>modules/convert/Test/ProcessManageConvertTest.php</file>-->
......
...@@ -30,13 +30,13 @@ abstract class ServiceModelAbstract ...@@ -30,13 +30,13 @@ abstract class ServiceModelAbstract
$name = defined((string) $value->name) ? constant((string) $value->name) : (string) $value->name; $name = defined((string) $value->name) ? constant((string) $value->name) : (string) $value->name;
$comment = defined((string) $value->comment) ? constant((string) $value->comment) : (string) $value->comment; $comment = defined((string) $value->comment) ? constant((string) $value->comment) : (string) $value->comment;
$services['application'][] = [ $services['application'][] = [
'id' => (string) $value->id, 'id' => (string) $value->id,
'name' => $name, 'name' => $name,
'comment' => $comment, 'comment' => $comment,
'servicepage' => (string) $value->servicepage, 'servicepage' => (string) $value->servicepage,
'style' => (string) $value->style, 'style' => (string) $value->style,
'system_service' => (string) $value->system_service == 'true' ? true : false, 'system_service' => (string) $value->system_service == 'true' ? true : false,
'servicetype' => (string) $value->servicetype, 'servicetype' => (string) $value->servicetype,
]; ];
} }
} }
...@@ -54,13 +54,13 @@ abstract class ServiceModelAbstract ...@@ -54,13 +54,13 @@ abstract class ServiceModelAbstract
$name = defined((string) $value->name) ? constant((string) $value->name) : (string) $value->name; $name = defined((string) $value->name) ? constant((string) $value->name) : (string) $value->name;
$comment = defined((string) $value->comment) ? constant((string) $value->comment) : (string) $value->comment; $comment = defined((string) $value->comment) ? constant((string) $value->comment) : (string) $value->comment;
$services[$module][] = [ $services[$module][] = [
'id' => (string) $value->id, 'id' => (string) $value->id,
'name' => $name, 'name' => $name,
'comment' => $comment, 'comment' => $comment,
'servicepage' => (string) $value->servicepage, 'servicepage' => (string) $value->servicepage,
'style' => (string) $value->style, 'style' => (string) $value->style,
'system_service' => (string) $value->system_service == 'true' ? true : false, 'system_service' => (string) $value->system_service == 'true' ? true : false,
'servicetype' => (string) $value->servicetype, 'servicetype' => (string) $value->servicetype,
]; ];
} }
} }
...@@ -82,11 +82,11 @@ abstract class ServiceModelAbstract ...@@ -82,11 +82,11 @@ abstract class ServiceModelAbstract
$name = defined((string) $value->name) ? constant((string) $value->name) : (string) $value->name; $name = defined((string) $value->name) ? constant((string) $value->name) : (string) $value->name;
$comment = defined((string) $value->comment) ? constant((string) $value->comment) : (string) $value->comment; $comment = defined((string) $value->comment) ? constant((string) $value->comment) : (string) $value->comment;
$applicationServices[$category][] = [ $applicationServices[$category][] = [
'name' => $name, 'name' => $name,
'comment' => $comment, 'comment' => $comment,
'servicepage' => (string) $value->servicepage, 'servicepage' => (string) $value->servicepage,
'style' => (string) $value->style, 'style' => (string) $value->style,
'angular' => empty((string) $value->angular) ? 'false' : (string) $value->angular, 'angular' => empty((string) $value->angular) ? 'false' : (string) $value->angular,
]; ];
} }
} }
...@@ -110,11 +110,11 @@ abstract class ServiceModelAbstract ...@@ -110,11 +110,11 @@ abstract class ServiceModelAbstract
$name = defined((string) $value->name) ? constant((string) $value->name) : (string) $value->name; $name = defined((string) $value->name) ? constant((string) $value->name) : (string) $value->name;
$comment = defined((string) $value->comment) ? constant((string) $value->comment) : (string) $value->comment; $comment = defined((string) $value->comment) ? constant((string) $value->comment) : (string) $value->comment;
$applicationServices[$category][] = [ $applicationServices[$category][] = [
'name' => $name, 'name' => $name,
'comment' => $comment, 'comment' => $comment,
'servicepage' => (string) $value->servicepage, 'servicepage' => (string) $value->servicepage,
'style' => (string) $value->style, 'style' => (string) $value->style,
'angular' => empty((string) $value->angular) ? 'false' : (string) $value->angular, 'angular' => empty((string) $value->angular) ? 'false' : (string) $value->angular,
]; ];
} }
} }
...@@ -139,11 +139,11 @@ abstract class ServiceModelAbstract ...@@ -139,11 +139,11 @@ abstract class ServiceModelAbstract
$name = defined((string) $value->name) ? constant((string) $value->name) : (string) $value->name; $name = defined((string) $value->name) ? constant((string) $value->name) : (string) $value->name;
$comment = defined((string) $value->comment) ? constant((string) $value->comment) : (string) $value->comment; $comment = defined((string) $value->comment) ? constant((string) $value->comment) : (string) $value->comment;
$modulesServices[$category][] = [ $modulesServices[$category][] = [
'name' => $name, 'name' => $name,
'comment' => $comment, 'comment' => $comment,
'servicepage' => (string) $value->servicepage, 'servicepage' => (string) $value->servicepage,
'style' => (string) $value->style, 'style' => (string) $value->style,
'angular' => empty((string) $value->angular) ? 'false' : (string) $value->angular, 'angular' => empty((string) $value->angular) ? 'false' : (string) $value->angular,
]; ];
} }
} }
...@@ -172,11 +172,11 @@ abstract class ServiceModelAbstract ...@@ -172,11 +172,11 @@ abstract class ServiceModelAbstract
$name = defined((string) $value->name) ? constant((string) $value->name) : (string) $value->name; $name = defined((string) $value->name) ? constant((string) $value->name) : (string) $value->name;
$comment = defined((string) $value->comment) ? constant((string) $value->comment) : (string) $value->comment; $comment = defined((string) $value->comment) ? constant((string) $value->comment) : (string) $value->comment;
$modulesServices[$category][] = [ $modulesServices[$category][] = [
'name' => $name, 'name' => $name,
'comment' => $comment, 'comment' => $comment,
'servicepage' => (string) $value->servicepage, 'servicepage' => (string) $value->servicepage,
'style' => (string) $value->style, 'style' => (string) $value->style,
'angular' => empty((string) $value->angular) ? 'false' : (string) $value->angular, 'angular' => empty((string) $value->angular) ? 'false' : (string) $value->angular,
]; ];
} }
} }
...@@ -195,10 +195,10 @@ abstract class ServiceModelAbstract ...@@ -195,10 +195,10 @@ abstract class ServiceModelAbstract
$label = defined((string) $value->libconst) ? constant((string) $value->libconst) : (string) $value->libconst; $label = defined((string) $value->libconst) ? constant((string) $value->libconst) : (string) $value->libconst;
$modulesServices['menuList'][] = [ $modulesServices['menuList'][] = [
'id' => (string) $value->id, 'id' => (string) $value->id,
'label' => $label, 'label' => $label,
'link' => (string) $value->url, 'link' => (string) $value->url,
'icon' => (string) $value->style, 'icon' => (string) $value->style,
'angular' => empty((string) $value->angular) ? 'false' : (string) $value->angular, 'angular' => empty((string) $value->angular) ? 'false' : (string) $value->angular,
]; ];
} }
...@@ -260,10 +260,10 @@ abstract class ServiceModelAbstract ...@@ -260,10 +260,10 @@ abstract class ServiceModelAbstract
$label = defined((string) $value->libconst) ? constant((string) $value->libconst) : (string) $value->libconst; $label = defined((string) $value->libconst) ? constant((string) $value->libconst) : (string) $value->libconst;
$modulesServices['menuList'][] = [ $modulesServices['menuList'][] = [
'id' => (string) $value->id, 'id' => (string) $value->id,
'label' => $label, 'label' => $label,
'link' => (string) $value->url, 'link' => (string) $value->url,
'icon' => (string) $value->style, 'icon' => (string) $value->style,
'angular' => empty((string) $value->angular) ? 'false' : (string) $value->angular, 'angular' => empty((string) $value->angular) ? 'false' : (string) $value->angular,
]; ];
} }
...@@ -291,10 +291,10 @@ abstract class ServiceModelAbstract ...@@ -291,10 +291,10 @@ abstract class ServiceModelAbstract
$label = defined((string) $value->libconst) ? constant((string) $value->libconst) : (string) $value->libconst; $label = defined((string) $value->libconst) ? constant((string) $value->libconst) : (string) $value->libconst;
$modulesServices['menuList'][] = [ $modulesServices['menuList'][] = [
'id' => (string) $value->id, 'id' => (string) $value->id,
'label' => $label, 'label' => $label,
'link' => (string) $value->url, 'link' => (string) $value->url,
'icon' => (string) $value->style, 'icon' => (string) $value->style,
'angular' => empty((string) $value->angular) ? 'false' : (string) $value->angular, 'angular' => empty((string) $value->angular) ? 'false' : (string) $value->angular,
]; ];
} }
...@@ -321,10 +321,10 @@ abstract class ServiceModelAbstract ...@@ -321,10 +321,10 @@ abstract class ServiceModelAbstract
$administrationApplication = ServiceModel::getApplicationAdministrationServicesByUserServices(['userServices' => $servicesStoredInDB]); $administrationApplication = ServiceModel::getApplicationAdministrationServicesByUserServices(['userServices' => $servicesStoredInDB]);
$administrationModule = ServiceModel::getModulesAdministrationServicesByUserServices(['userServices' => $servicesStoredInDB]); $administrationModule = ServiceModel::getModulesAdministrationServicesByUserServices(['userServices' => $servicesStoredInDB]);
foreach($administrationApplication['supervision'] as $key => $value){ foreach ($administrationApplication['supervision'] as $key => $value) {
if($value['name'] == "Historique des batchs"){ if ($value['name'] == "Historique des batchs") {
array_splice($administrationApplication['supervision'], $key, 1); array_splice($administrationApplication['supervision'], $key, 1);
} }
} }
unset($key); unset($key);
......
...@@ -37,7 +37,7 @@ class CoreController ...@@ -37,7 +37,7 @@ class CoreController
$aInit['scriptsToinject'] = []; $aInit['scriptsToinject'] = [];
$scriptsToInject = scandir('dist'); $scriptsToInject = scandir('dist');
foreach ($scriptsToInject as $key => $value) { foreach ($scriptsToInject as $value) {
if (strstr($value, 'runtime.') !== false || strstr($value, 'main.') !== false || strstr($value, 'vendor.') !== false || strstr($value, 'scripts.') !== false) { if (strstr($value, 'runtime.') !== false || strstr($value, 'main.') !== false || strstr($value, 'vendor.') !== false || strstr($value, 'scripts.') !== false) {
if (strstr($value, '.js.map') === false) { if (strstr($value, '.js.map') === false) {
$aInit['scriptsToinject'][] = $value; $aInit['scriptsToinject'][] = $value;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment