mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 16:24:04 +02:00
Fix Codestyle/PHPDoc, fix configPath being Overwritten
Also removed possibility to disable debugging as there's no use case for this refs #4525 refs #4598
This commit is contained in:
parent
49d92d0c33
commit
a6ff6ecadd
@ -93,6 +93,7 @@ class ConfigController extends BaseConfigController
|
|||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
$form = new GeneralForm();
|
$form = new GeneralForm();
|
||||||
|
|
||||||
$form->setConfiguration(IcingaConfig::app());
|
$form->setConfiguration(IcingaConfig::app());
|
||||||
$form->setRequest($this->_request);
|
$form->setRequest($this->_request);
|
||||||
if ($form->isSubmittedAndValid()) {
|
if ($form->isSubmittedAndValid()) {
|
||||||
@ -116,7 +117,7 @@ class ConfigController extends BaseConfigController
|
|||||||
if ($form->isSubmittedAndValid()) {
|
if ($form->isSubmittedAndValid()) {
|
||||||
$config = $form->getConfig();
|
$config = $form->getConfig();
|
||||||
if (!$this->writeConfigFile($form->getConfig(), 'config')) {
|
if (!$this->writeConfigFile($form->getConfig(), 'config')) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
$this->redirectNow('/config/logging');
|
$this->redirectNow('/config/logging');
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ class GeneralForm extends Form
|
|||||||
array(
|
array(
|
||||||
'label' => 'Development mode',
|
'label' => 'Development mode',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'helptesxt' => 'Set true to show more detailed errors '
|
'helptext' => 'Set true to show more detailed errors '
|
||||||
. 'and disable certain optimizations '
|
. 'and disable certain optimizations '
|
||||||
. 'in order to make debugging easier.',
|
. 'in order to make debugging easier.',
|
||||||
'tooltip' => 'More verbose output',
|
'tooltip' => 'More verbose output',
|
||||||
@ -267,6 +267,7 @@ class GeneralForm extends Form
|
|||||||
'value' => $cfg->get('configPath')
|
'value' => $cfg->get('configPath')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$backends = array();
|
$backends = array();
|
||||||
foreach ($this->getResources() as $name => $resource) {
|
foreach ($this->getResources() as $name => $resource) {
|
||||||
if ($resource['type'] !== 'db') {
|
if ($resource['type'] !== 'db') {
|
||||||
@ -285,7 +286,9 @@ class GeneralForm extends Form
|
|||||||
'multiOptions' => $backends
|
'multiOptions' => $backends
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$txtPreferencesIniPath->addValidator(new WritablePathValidator());
|
$validator = new WritablePathValidator();
|
||||||
|
$validator->setRequireExistence();
|
||||||
|
$txtPreferencesIniPath->addValidator($validator);
|
||||||
$this->addElement($txtPreferencesIniPath);
|
$this->addElement($txtPreferencesIniPath);
|
||||||
$this->addElement($txtPreferencesDbResource);
|
$this->addElement($txtPreferencesDbResource);
|
||||||
|
|
||||||
@ -313,6 +316,7 @@ class GeneralForm extends Form
|
|||||||
$global = new Zend_Config(array());
|
$global = new Zend_Config(array());
|
||||||
}
|
}
|
||||||
$preferences = $this->config->preferences;
|
$preferences = $this->config->preferences;
|
||||||
|
|
||||||
if ($preferences === null) {
|
if ($preferences === null) {
|
||||||
$preferences = new Zend_Config(array());
|
$preferences = new Zend_Config(array());
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ class LoggingForm extends Form
|
|||||||
if ($this->baseDir) {
|
if ($this->baseDir) {
|
||||||
return $this->baseDir;
|
return $this->baseDir;
|
||||||
}
|
}
|
||||||
return realpath(Icinga::app()->getApplicationDir().'/../');
|
return realpath(Icinga::app()->getApplicationDir() . '/../');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -117,23 +117,6 @@ class LoggingForm extends Form
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true when logging is enabled according to the request and the configuration
|
|
||||||
*
|
|
||||||
* @param Zend_Config $config The logging section of the config.ini
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function loggingIsEnabled(Zend_Config $config)
|
|
||||||
{
|
|
||||||
$loggingRequestParam = $this->getRequest()->getParam('logging_enable', null);
|
|
||||||
|
|
||||||
if ($loggingRequestParam !== null) {
|
|
||||||
return intval($loggingRequestParam) === 1;
|
|
||||||
} else {
|
|
||||||
return intval($config->get('enable', 0)) === 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create this logging configuration form
|
* Create this logging configuration form
|
||||||
*
|
*
|
||||||
@ -154,30 +137,6 @@ class LoggingForm extends Form
|
|||||||
if ($debug === null) {
|
if ($debug === null) {
|
||||||
$debug = new IcingaConfig(array());
|
$debug = new IcingaConfig(array());
|
||||||
}
|
}
|
||||||
$this->addElement(
|
|
||||||
'checkbox',
|
|
||||||
'logging_enable',
|
|
||||||
array(
|
|
||||||
'label' => 'Logging enabled',
|
|
||||||
'required' => true,
|
|
||||||
'value' => $this->loggingIsEnabled($logging)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
if (!$this->loggingIsEnabled($logging)) {
|
|
||||||
$this->addElement(
|
|
||||||
new Note(
|
|
||||||
array(
|
|
||||||
'name' => 'note_logging_disabled',
|
|
||||||
'value' => 'Logging is disabled.'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$this->setSubmitLabel('Save changes');
|
|
||||||
$this->enableAutoSubmit(array('logging_enable'));
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$txtLogPath = new Zend_Form_Element_Text(
|
$txtLogPath = new Zend_Form_Element_Text(
|
||||||
array(
|
array(
|
||||||
@ -231,7 +190,7 @@ class LoggingForm extends Form
|
|||||||
$textLoggingDebugPath->addDecorator($decorator);
|
$textLoggingDebugPath->addDecorator($decorator);
|
||||||
|
|
||||||
|
|
||||||
$this->enableAutoSubmit(array('logging_debug_enable', 'logging_enable'));
|
$this->enableAutoSubmit(array('logging_debug_enable'));
|
||||||
|
|
||||||
$this->setSubmitLabel('Save changes');
|
$this->setSubmitLabel('Save changes');
|
||||||
}
|
}
|
||||||
@ -257,7 +216,7 @@ class LoggingForm extends Form
|
|||||||
$values = $this->getValues();
|
$values = $this->getValues();
|
||||||
$cfg = $this->config->toArray();
|
$cfg = $this->config->toArray();
|
||||||
|
|
||||||
$cfg['logging']['enable'] = intval($values['logging_enable']);
|
$cfg['logging']['enable'] = 1;
|
||||||
$cfg['logging']['type'] = 'stream';
|
$cfg['logging']['type'] = 'stream';
|
||||||
$cfg['logging']['verbose'] = $values['logging_app_verbose'];
|
$cfg['logging']['verbose'] = $values['logging_app_verbose'];
|
||||||
$cfg['logging']['target'] = $values['logging_app_target'];
|
$cfg['logging']['target'] = $values['logging_app_target'];
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?= $this->tabs->render($this); ?>
|
<?= $this->tabs->render($this); ?>
|
||||||
|
|
||||||
<?php $errors = $this->form->getErrorMessages(); ?>
|
<?php $errors = $this->form->getErrorMessages(); ?>
|
||||||
|
|
||||||
<?php if (!empty($errors)) : ?>
|
<?php if (!empty($errors)) : ?>
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
<h4>Errors occured when trying to save the project</h4>
|
<h4>Errors occured when trying to save the project</h4>
|
||||||
|
@ -35,6 +35,7 @@ use Icinga\User;
|
|||||||
use Icinga\Web\Request;
|
use Icinga\Web\Request;
|
||||||
use Zend_Controller_Front;
|
use Zend_Controller_Front;
|
||||||
use Zend_Layout;
|
use Zend_Layout;
|
||||||
|
use Zend_Config;
|
||||||
use Zend_Paginator;
|
use Zend_Paginator;
|
||||||
use Zend_View_Helper_PaginationControl;
|
use Zend_View_Helper_PaginationControl;
|
||||||
use Zend_Controller_Action_HelperBroker;
|
use Zend_Controller_Action_HelperBroker;
|
||||||
@ -225,7 +226,9 @@ class Web extends ApplicationBootstrap
|
|||||||
|
|
||||||
$user = $authenticationManager->getUser();
|
$user = $authenticationManager->getUser();
|
||||||
|
|
||||||
$this->getConfig()->preferences->configPath = $this->getConfigDir('preferences');
|
$this->getConfig()->preferences->configPath = Config::app()
|
||||||
|
->get('preferences', new Zend_Config(array()))
|
||||||
|
->get('configPath', $this->getConfigDir('preferences'));
|
||||||
|
|
||||||
$preferenceStore = StoreFactory::create(
|
$preferenceStore = StoreFactory::create(
|
||||||
$this->getConfig()->preferences,
|
$this->getConfig()->preferences,
|
||||||
|
@ -37,10 +37,17 @@ class Note extends Zend_Form_Element_Xhtml
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Name of the view helper
|
* Name of the view helper
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $helper = 'formNote';
|
public $helper = 'formNote';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true to ensure redrawing
|
||||||
|
*
|
||||||
|
* @param mixed $value The value of to validate (ignored)
|
||||||
|
* @return bool Always true
|
||||||
|
*/
|
||||||
public function isValid($value)
|
public function isValid($value)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -44,10 +44,26 @@ class WritablePathValidator extends Zend_Validate_Abstract
|
|||||||
*/
|
*/
|
||||||
// @codingStandardsIgnoreStart
|
// @codingStandardsIgnoreStart
|
||||||
protected $_messageTemplates = array(
|
protected $_messageTemplates = array(
|
||||||
'NOT_WRITABLE' => 'Path is not writable'
|
'NOT_WRITABLE' => 'Path is not writable',
|
||||||
|
'DOES_NOT_EXIST'=> 'Path does not exist'
|
||||||
);
|
);
|
||||||
// @codingStandardsIgnoreEnd
|
// @codingStandardsIgnoreEnd
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When true, the file or directory must exist
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $requireExistence = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set this validator to require the target file to exist
|
||||||
|
*/
|
||||||
|
public function setRequireExistence()
|
||||||
|
{
|
||||||
|
$this->requireExistence = true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the given value is writable path
|
* Check whether the given value is writable path
|
||||||
*
|
*
|
||||||
@ -62,8 +78,14 @@ class WritablePathValidator extends Zend_Validate_Abstract
|
|||||||
$value = (string) $value;
|
$value = (string) $value;
|
||||||
$this->_setValue($value);
|
$this->_setValue($value);
|
||||||
|
|
||||||
|
if ($this->requireExistence && !file_exists($value)) {
|
||||||
|
$this->_error('DOES_NOT_EXIST');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ((file_exists($value) && is_writable($value)) ||
|
if ((file_exists($value) && is_writable($value)) ||
|
||||||
(is_dir(dirname($value)) != '' && is_writable(dirname($value)))) {
|
(is_dir(dirname($value)) && is_writable(dirname($value)))
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$this->_error('NOT_WRITABLE');
|
$this->_error('NOT_WRITABLE');
|
||||||
|
@ -36,17 +36,17 @@ class Monitoring_ConfigController extends BaseConfigController {
|
|||||||
static public function createProvidedTabs()
|
static public function createProvidedTabs()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
"backends" => new Tab(array(
|
'backends' => new Tab(array(
|
||||||
"name" => "backends",
|
'name' => 'backends',
|
||||||
"title" => "Monitoring Backends",
|
'title' => 'Monitoring Backends',
|
||||||
"url" => Url::fromPath("/monitoring/config/backend")
|
'url' => Url::fromPath('/monitoring/config/backend')
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function backendAction()
|
public function backendAction()
|
||||||
{
|
{
|
||||||
$this->redirectNow("/config");
|
$this->redirectNow('/config');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -71,11 +71,7 @@ class LoggingFormTest extends BaseFormTest
|
|||||||
$form->setConfiguration($config);
|
$form->setConfiguration($config);
|
||||||
$form->setBaseDir('basedir');
|
$form->setBaseDir('basedir');
|
||||||
$form->create();
|
$form->create();
|
||||||
$this->assertEquals(
|
|
||||||
'1',
|
|
||||||
$form->getValue('logging_enable'),
|
|
||||||
'Asserting the logging enable tick to be set'
|
|
||||||
);
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'0',
|
'0',
|
||||||
$form->getValue('logging_app_verbose'),
|
$form->getValue('logging_app_verbose'),
|
||||||
@ -171,44 +167,4 @@ class LoggingFormTest extends BaseFormTest
|
|||||||
'Asserting the debug log target modifications to be applied'
|
'Asserting the debug log target modifications to be applied'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test form elements to be hidden when logging is disabled
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function testLoggingDisabled()
|
|
||||||
{
|
|
||||||
date_default_timezone_set('UTC');
|
|
||||||
$form = $this->getRequestForm(
|
|
||||||
array(),
|
|
||||||
'Icinga\Form\Config\LoggingForm'
|
|
||||||
);
|
|
||||||
$baseConfig = new Zend_Config(
|
|
||||||
array(
|
|
||||||
'global' => array(
|
|
||||||
'option' => 'value'
|
|
||||||
),
|
|
||||||
'logging' => array(
|
|
||||||
'enable' => 0,
|
|
||||||
'target' => '/some/path',
|
|
||||||
'verbose' => 0,
|
|
||||||
'type' => 'stream',
|
|
||||||
'debug' => array(
|
|
||||||
'enable' => 1,
|
|
||||||
'target' => '/some/debug/path',
|
|
||||||
'type' => 'stream'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$form->setConfiguration($baseConfig);
|
|
||||||
|
|
||||||
$form->create();
|
|
||||||
$this->assertEquals(
|
|
||||||
null,
|
|
||||||
$form->getElement('logging_app_target'),
|
|
||||||
'Asserting no fields being rendered when logging is off'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Test\Icinga\Web\Form\Validator;
|
||||||
|
|
||||||
|
require_once('Zend/Validate/Abstract.php');
|
||||||
|
require_once(realpath('../../library/Icinga/Web/Form/Validator/DateFormatValidator.php'));
|
||||||
|
|
||||||
|
use \PHPUnit_Framework_TestCase;
|
||||||
|
use \Icinga\Web\Form\Validator\DateFormatValidator;
|
||||||
|
|
||||||
|
class DateFormatValidatorTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public function testValidateCorrectInput()
|
||||||
|
{
|
||||||
|
$validator = new DateFormatValidator();
|
||||||
|
$this->assertTrue(
|
||||||
|
$validator->isValid(
|
||||||
|
'Y-m-d',
|
||||||
|
'Asserting a valid date format to result in correct validation'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testValidateInorrectInput()
|
||||||
|
{
|
||||||
|
$validator = new DateFormatValidator();
|
||||||
|
$this->assertFalse(
|
||||||
|
$validator->isValid(
|
||||||
|
'Y-m-d h:m:s',
|
||||||
|
'Asserting a date format combined with time to result in a validation error'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Test\Icinga\Web\Form\Validator;
|
||||||
|
|
||||||
|
require_once('Zend/Validate/Abstract.php');
|
||||||
|
require_once(realpath('../../library/Icinga/Web/Form/Validator/TimeFormatValidator.php'));
|
||||||
|
|
||||||
|
use \PHPUnit_Framework_TestCase;
|
||||||
|
use \Icinga\Web\Form\Validator\TimeFormatValidator;
|
||||||
|
|
||||||
|
class TimeFormatValidatorTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public function testValidateCorrectInput()
|
||||||
|
{
|
||||||
|
$validator = new TimeFormatValidator();
|
||||||
|
$this->assertTrue(
|
||||||
|
$validator->isValid(
|
||||||
|
'h-i-s',
|
||||||
|
'Asserting a valid time format to result in correct validation'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testValidateInorrectInput()
|
||||||
|
{
|
||||||
|
$validator = new TimeFormatValidator();
|
||||||
|
$this->assertFalse(
|
||||||
|
$validator->isValid(
|
||||||
|
'Y-m-d h:m:s',
|
||||||
|
'Asserting a date format combined with time to result in a validation error'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Test\Icinga\Web\Form\Validator;
|
||||||
|
|
||||||
|
require_once('Zend/Validate/Abstract.php');
|
||||||
|
require_once(realpath('../../library/Icinga/Web/Form/Validator/WritablePathValidator.php'));
|
||||||
|
|
||||||
|
use \PHPUnit_Framework_TestCase;
|
||||||
|
use \Icinga\Web\Form\Validator\WritablePathValidator;
|
||||||
|
|
||||||
|
class WritablePathValidatorTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public function testValidateInputWithWritablePath()
|
||||||
|
{
|
||||||
|
$validator = new WritablePathValidator();
|
||||||
|
if (!is_writeable('/tmp')) {
|
||||||
|
$this->markTestSkipped('Need /tmp to be writable for testing WritablePathValidator');
|
||||||
|
}
|
||||||
|
$this->assertTrue(
|
||||||
|
$validator->isValid(
|
||||||
|
'/tmp/test',
|
||||||
|
'Asserting a writable path to result in correct validation'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testValidateInputWithNonWritablePath()
|
||||||
|
{
|
||||||
|
$validator = new WritablePathValidator();
|
||||||
|
$this->assertFalse(
|
||||||
|
$validator->isValid(
|
||||||
|
'/etc/shadow',
|
||||||
|
'Asserting a non writable path to result in a validation error'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user