Commit f3690a7f authored by Patrick Barroca's avatar Patrick Barroca 😁
Browse files

Merge branch...

Merge branch 'dev#88091_shooting_rajouter_les_ips_publiques_dans_shooting_pour_filtrage_acces_serveur_cache' into 'master'

dev #88091 : shooting : add public ip adress

See merge request !3093
parents 03cd5247 282243c3
Pipeline #6792 passed with stage
in 37 minutes and 12 seconds
- ticket #88091 : Administration : Ajout d'informations dans le rapport d'état système
\ No newline at end of file
......@@ -40,11 +40,17 @@ class ProfilLoader extends Storm_Model_Loader {
}
ksort($profils_by_bib);
return $profils_by_bib;
}
public function getAllModules() {
return (new Storm_Model_Collection(Class_Profil::findAll()))
->collect('modules')
->getArrayCopy();
}
public function findAllByZoneAndBib($id_zone=0,$id_bib=0) {
$conditions = array('order' => 'libelle');
......
......@@ -20,6 +20,8 @@
*/
class Class_Systeme_Report extends Class_Systeme_Report_Abstract {
public function acceptVisitor($visitor) {
$visitor->visitSection('headers' ,
$this->_('Entêtes'),
......@@ -79,7 +81,6 @@ class Class_Systeme_Report_Headers extends Class_Systeme_Report_Abstract {
$this->_('Base de données'),
array_at('dbname',
Zend_Db_Table::getDefaultAdapter()->getConfig()));
$visitor->visitData('php', $this->_('PHP'), PHP_VERSION);
}
}
......@@ -88,10 +89,16 @@ class Class_Systeme_Report_Headers extends Class_Systeme_Report_Abstract {
class Class_Systeme_Report_Portal extends Class_Systeme_Report_Abstract {
use Trait_SimpleWebClient;
const EXTERNAL_IP_URL = 'http://myexternalip.com/raw';
public function acceptVisitor($visitor) {
$visitor->visitData('url', $this->_('URL principale'), Class_Url::absolute('',null,true));
$visitor->visitData('url', $this->_('URL principale'), Class_Url::absolute('', null, true));
$visitor->visitData('ip', $this->_('IP publique'),
$this->getWebClient()->open_url(static::EXTERNAL_IP_URL));
$visitor->visitData('label', $this->_('Libellé principal'), Class_Profil::getPortail()->getLibelle());
$visitor->visitDataArray('skins', $this->_('Thèmes utilisés'), $this->_profilSkins());
$visitor->visitDataArray('boxes', $this->_('Boites utilisées'), $this->_profilBoxes());
$visitor->visitDataArray('tags', $this->_('Tags'), $this->_fetchTags());
}
......@@ -105,6 +112,24 @@ class Class_Systeme_Report_Portal extends Class_Systeme_Report_Abstract {
}
protected function _profilBoxes() {
$list = [];
foreach (Class_Profil::getAllModules() as $modules)
$list = $this->_boxTypeFrom($modules, $list);
return array_values(array_filter($list));
}
protected function _boxTypeFrom($modules, $list) {
foreach ($modules as $module)
if (isset($module['type_module']))
$list[$module['type_module']] = $module['type_module'];
return $list;
}
protected function _fetchTags() {
$tags = (string)Class_AdminVar::get('STATUS_REPORT_TAGS');
if (defined('STATUS_REPORT_TAGS'))
......
......@@ -22,8 +22,6 @@
abstract class Class_Systeme_Report_Abstract {
use Trait_Translator, Trait_TimeSource;
abstract public function acceptVisitor($visitor);
}
?>
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
trait Trait_SimpleWebClient {
protected static $_web_client;
public static function setWebClient($client) {
static::$_web_client = $client;
}
public static function getWebClient() {
return isset(static::$_web_client)
? static::$_web_client
: new Class_WebService_SimpleWebClient();
}
}
......@@ -98,6 +98,14 @@ class ZendAfi_View_Helper_Status_HtmlTest extends ZendAfi_View_Helper_Status_Tes
}
/** @test */
public function boxesListShouldBeSearchAndLogin() {
$this->assertXPathContentContains($this->_html,
'//dd[preceding-sibling::dt[text()="Boites utilisées"]]',
'RECH_SIMPLE, LOGIN');
}
/** @test */
public function usedSpaceShouldBe10Mo() {
$this->assertXPathContentContains($this->_html,
......@@ -113,6 +121,11 @@ class ZendAfi_View_Helper_Status_HtmlTest extends ZendAfi_View_Helper_Status_Tes
'0 o');
}
/** @test */
public function ipAdressShouldBe70070012() {
$this->assertXPathContentContains($this->_html,
'//dd[preceding-sibling::dt[text()="IP publique"]]','700.700.1.2');
}
/** @test */
public function totalSpaceShouldBe10Mo() {
......
......@@ -44,6 +44,12 @@ class ZendAfi_View_Helper_Status_JsonTest extends ZendAfi_View_Helper_Status_Tes
}
/** @test */
public function ipAdressShouldBe70070012() {
$this->assertEquals('700.700.1.2', $this->_report['portal']['ip']);
}
/** @test */
public function portalTagsShouldContainsTestingIgnoreInProdAndDedicatedServer() {
$this->assertEquals(['TESTING', 'IGNORE', 'IN_PROD', 'Personnalisé', 'Par défaut', 'DEDICATED_SERVER'],
......@@ -347,5 +353,13 @@ class ZendAfi_View_Helper_Status_JsonTest extends ZendAfi_View_Helper_Status_Tes
$this->_report['variables']);;
}
/** @test */
public function boxesListShouldBeDiplayed() {
$this->assertEquals(['RECH_SIMPLE',
'LOGIN'],
$this->_report['portal']['boxes']);;
}
}
?>
\ No newline at end of file
......@@ -20,6 +20,8 @@
*/
require_once 'tests/fixtures/KohaFixtures.php';
require_once 'library/Class/Systeme/Report.php';
abstract class ZendAfi_View_Helper_Status_TestCase extends ViewHelperTestCase {
protected
$_storm_default_to_volatile = true,
......@@ -41,11 +43,22 @@ abstract class ZendAfi_View_Helper_Status_TestCase extends ViewHelperTestCase {
'parent_id' => null,
'skin' => 'quiet_lake']);
$cfg_accueil = ['modules' => ['1' => ['division' => '1',
'type_module' => 'RECH_SIMPLE',
'preferences' => ['header_css'=>'afi-opac3/userfiles/jeunesse.css']],
'3' => ['division' => '4',
'type_module' => 'LOGIN',
'preferences' => ['titre'=>'Connection']]],
'options' => []];
$this->fixture('Class_Profil',
['id' => 35,
'libelle' => 'Annecy-Le-Vieux',
'parent_id' => null,
'skin' => 'quiet_lake']);
'skin' => 'quiet_lake',
'cfg_accueil' => $cfg_accueil]);
return $this;
}
......@@ -158,6 +171,7 @@ abstract class ZendAfi_View_Helper_Status_TestCase extends ViewHelperTestCase {
protected function _setupBokeh() {
Class_AdminVar::set('NOM_DOMAINE', 'library.annecy.fr');
$this
->_setupProfils()
->_setupCosmogramme()
......@@ -182,6 +196,14 @@ abstract class ZendAfi_View_Helper_Status_TestCase extends ViewHelperTestCase {
$this->_helper = new $this->_helper_class();
$this->_helper->setView($view);
Class_Url::setPhpMode(null);
$mock_webclient = $this->mock();
$mock_webclient->whenCalled('open_url')
->with(Class_Systeme_Report_Portal::EXTERNAL_IP_URL)
->answers('700.700.1.2')
->beStrict();
Class_Systeme_Report_Portal::setWebClient($mock_webclient);
$this->_setupBokeh();
$this->_setupVars();
$time_source = new TimeSourceForTest('2016-12-05 11:00:00');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment