Merge branch 'master' into feature/setup-wizard-7163
Conflicts: application/forms/Config/Resource/LdapResourceForm.php test/php/application/forms/Config/Authentication/LdapBackendFormTest.php
This commit is contained in:
commit
9d292269b1
|
@ -76,7 +76,7 @@ __function createService(service_type, num) {
|
|||
enable_active_checks = (service_type != "pending")
|
||||
vars.check_type = service_type
|
||||
|
||||
assign where match("*" + service_type + "*", host.vars.check_config)
|
||||
assign where service_type in host.vars.check_config
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,12 +102,12 @@ __function createHost(checkType, checkConfig, num, checkEnabled) {
|
|||
}
|
||||
|
||||
__for (num in range(10)) {
|
||||
createHost("ok", "ok", num, true)
|
||||
createHost("random", "random,flapping", num, true)
|
||||
createHost("down", "warning,critical", num, true)
|
||||
createHost("unreachable", "unknown", num, true)
|
||||
createHost("pending", "pending", num, false)
|
||||
createHost("flap", "flapping", num, true)
|
||||
createHost("ok", [ "ok" ], num, true)
|
||||
createHost("random", [ "random", "flapping" ], num, true)
|
||||
createHost("down", [ "warning", "critical" ], num, true)
|
||||
createHost("unreachable", [ "unknown" ], num, true)
|
||||
createHost("pending", [ "pending" ], num, false)
|
||||
createHost("flap", [ "flapping" ], num, true)
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
|
|
@ -7,7 +7,7 @@ use Icinga\Web\Notification;
|
|||
use Icinga\Application\Modules\Module;
|
||||
use Icinga\Web\Widget;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Application\Config as IcingaConfig;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Form\Config\GeneralConfigForm;
|
||||
use Icinga\Form\Config\AuthenticationBackendReorderForm;
|
||||
use Icinga\Form\Config\AuthenticationBackendConfigForm;
|
||||
|
@ -46,7 +46,7 @@ class ConfigController extends ActionController
|
|||
public function indexAction()
|
||||
{
|
||||
$form = new GeneralConfigForm();
|
||||
$form->setIniConfig(IcingaConfig::app());
|
||||
$form->setIniConfig(Config::app());
|
||||
$form->handleRequest();
|
||||
|
||||
$this->view->form = $form;
|
||||
|
@ -131,7 +131,7 @@ class ConfigController extends ActionController
|
|||
public function authenticationAction()
|
||||
{
|
||||
$form = new AuthenticationBackendReorderForm();
|
||||
$form->setIniConfig(IcingaConfig::app('authentication'));
|
||||
$form->setIniConfig(Config::app('authentication'));
|
||||
$form->handleRequest();
|
||||
|
||||
$this->view->form = $form;
|
||||
|
@ -145,7 +145,7 @@ class ConfigController extends ActionController
|
|||
public function createauthenticationbackendAction()
|
||||
{
|
||||
$form = new AuthenticationBackendConfigForm();
|
||||
$form->setIniConfig(IcingaConfig::app('authentication'));
|
||||
$form->setIniConfig(Config::app('authentication'));
|
||||
$form->setResourceConfig(ResourceFactory::getResourceConfigs());
|
||||
$form->setRedirectUrl('config/authentication');
|
||||
$form->handleRequest();
|
||||
|
@ -161,7 +161,7 @@ class ConfigController extends ActionController
|
|||
public function editauthenticationbackendAction()
|
||||
{
|
||||
$form = new AuthenticationBackendConfigForm();
|
||||
$form->setIniConfig(IcingaConfig::app('authentication'));
|
||||
$form->setIniConfig(Config::app('authentication'));
|
||||
$form->setResourceConfig(ResourceFactory::getResourceConfigs());
|
||||
$form->setRedirectUrl('config/authentication');
|
||||
$form->handleRequest();
|
||||
|
@ -179,7 +179,7 @@ class ConfigController extends ActionController
|
|||
$form = new ConfirmRemovalForm(array(
|
||||
'onSuccess' => function ($request) {
|
||||
$configForm = new AuthenticationBackendConfigForm();
|
||||
$configForm->setIniConfig(IcingaConfig::app('authentication'));
|
||||
$configForm->setIniConfig(Config::app('authentication'));
|
||||
$authBackend = $request->getQuery('auth_backend');
|
||||
|
||||
try {
|
||||
|
@ -212,7 +212,7 @@ class ConfigController extends ActionController
|
|||
*/
|
||||
public function resourceAction()
|
||||
{
|
||||
$this->view->resources = IcingaConfig::app('resources', true)->toArray();
|
||||
$this->view->resources = Config::app('resources', true)->toArray();
|
||||
$this->view->tabs->activate('resources');
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ class ConfigController extends ActionController
|
|||
public function createresourceAction()
|
||||
{
|
||||
$form = new ResourceConfigForm();
|
||||
$form->setIniConfig(IcingaConfig::app('resources'));
|
||||
$form->setIniConfig(Config::app('resources'));
|
||||
$form->setRedirectUrl('config/resource');
|
||||
$form->handleRequest();
|
||||
|
||||
|
@ -236,7 +236,7 @@ class ConfigController extends ActionController
|
|||
public function editresourceAction()
|
||||
{
|
||||
$form = new ResourceConfigForm();
|
||||
$form->setIniConfig(IcingaConfig::app('resources'));
|
||||
$form->setIniConfig(Config::app('resources'));
|
||||
$form->setRedirectUrl('config/resource');
|
||||
$form->handleRequest();
|
||||
|
||||
|
@ -252,7 +252,7 @@ class ConfigController extends ActionController
|
|||
$form = new ConfirmRemovalForm(array(
|
||||
'onSuccess' => function ($request) {
|
||||
$configForm = new ResourceConfigForm();
|
||||
$configForm->setIniConfig(IcingaConfig::app('resources'));
|
||||
$configForm->setIniConfig(Config::app('resources'));
|
||||
$resource = $request->getQuery('resource');
|
||||
|
||||
try {
|
||||
|
@ -274,7 +274,7 @@ class ConfigController extends ActionController
|
|||
|
||||
// Check if selected resource is currently used for authentication
|
||||
$resource = $this->getRequest()->getQuery('resource');
|
||||
$authConfig = IcingaConfig::app('authentication')->toArray();
|
||||
$authConfig = Config::app('authentication')->toArray();
|
||||
foreach ($authConfig as $backendName => $config) {
|
||||
if (array_key_exists('resource', $config) && $config['resource'] === $resource) {
|
||||
$form->addError(sprintf(
|
||||
|
|
|
@ -93,7 +93,7 @@ class DashboardController extends ActionController
|
|||
);
|
||||
|
||||
$configFile = Config::app('dashboard/dashboard')->getConfigFile();
|
||||
if ($this->writeConfiguration(new Zend_Config($dashboard->toArray()), $configFile)) {
|
||||
if ($this->writeConfiguration(new Config($dashboard->toArray()), $configFile)) {
|
||||
$this->redirectNow(Url::fromPath('dashboard', array('pane' => $form->getValue('pane'))));
|
||||
} else {
|
||||
$this->render('showConfiguration');
|
||||
|
@ -151,12 +151,12 @@ class DashboardController extends ActionController
|
|||
/**
|
||||
* Store the given configuration as INI file
|
||||
*
|
||||
* @param Zend_Config $config The configuration to store
|
||||
* @param string $target The path where to store the configuration
|
||||
* @param Config $config The configuration to store
|
||||
* @param string $target The path where to store the configuration
|
||||
*
|
||||
* @return bool Whether the configuartion has been successfully stored
|
||||
*/
|
||||
protected function writeConfiguration(Zend_Config $config, $target)
|
||||
protected function writeConfiguration(Config $config, $target)
|
||||
{
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
use Icinga\Module\Monitoring\Controller;
|
||||
use Icinga\Web\Hook;
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Protocol\File\FileReader;
|
||||
use \Zend_Controller_Action_Exception as ActionError;
|
||||
|
||||
|
@ -48,7 +48,7 @@ class ListController extends Controller
|
|||
. ' - (?<message>.*)$/'; // message
|
||||
|
||||
$loggerWriter = Logger::getInstance()->getWriter();
|
||||
$resource = new FileReader(new Zend_Config(array(
|
||||
$resource = new FileReader(new Config(array(
|
||||
'filename' => $loggerWriter->getPath(),
|
||||
'fields' => $pattern
|
||||
)));
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace Icinga\Form\Config\Resource;
|
||||
|
||||
use Exception;
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Web\Form\Element\Number;
|
||||
|
@ -132,7 +132,7 @@ class DbResourceForm extends Form
|
|||
public static function isValidResource(Form $form)
|
||||
{
|
||||
try {
|
||||
$resource = ResourceFactory::createResource(new Zend_Config($form->getValues()));
|
||||
$resource = ResourceFactory::createResource(new Config($form->getValues()));
|
||||
$resource->getConnection()->getConnection();
|
||||
} catch (Exception $e) {
|
||||
$form->addError(t('Connectivity validation failed, connection to the given resource not possible.'));
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace Icinga\Form\Config\Resource;
|
||||
|
||||
use Exception;
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Web\Form\Element\Number;
|
||||
|
@ -113,7 +113,7 @@ class LdapResourceForm extends Form
|
|||
public static function isValidResource(Form $form)
|
||||
{
|
||||
try {
|
||||
$resource = ResourceFactory::createResource(new Zend_Config($form->getValues()));
|
||||
$resource = ResourceFactory::createResource(new Config($form->getValues()));
|
||||
if (false === $resource->testCredentials(
|
||||
$form->getElement('bind_dn')->getValue(),
|
||||
$form->getElement('bind_pw')->getValue()
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace Icinga\Form\Config\Resource;
|
||||
|
||||
use Exception;
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Application\Icinga;
|
||||
|
@ -74,7 +74,7 @@ class LivestatusResourceForm extends Form
|
|||
public static function isValidResource(Form $form)
|
||||
{
|
||||
try {
|
||||
$resource = ResourceFactory::createResource(new Zend_Config($form->getValues()));
|
||||
$resource = ResourceFactory::createResource(new Config($form->getValues()));
|
||||
$resource->connect()->disconnect();
|
||||
} catch (Exception $e) {
|
||||
$form->addError(t('Connectivity validation failed, connection to the given resource not possible.'));
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Icinga\Form\Dashboard;
|
||||
|
||||
use Icinga\Application\Config as IcingaConfig;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Widget\Dashboard;
|
||||
use Icinga\Web\Form;
|
||||
|
||||
|
@ -110,7 +110,7 @@ class AddUrlForm extends Form
|
|||
protected function getDashboardPaneSelectionValues()
|
||||
{
|
||||
$dashboard = new Dashboard();
|
||||
$dashboard->readConfig(IcingaConfig::app('dashboard/dashboard'));
|
||||
$dashboard->readConfig(Config::app('dashboard/dashboard'));
|
||||
return $dashboard->getPaneKeyTitleArray();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ namespace Icinga\Application;
|
|||
|
||||
use ErrorException;
|
||||
use Exception;
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Modules\Manager as ModuleManager;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
|
@ -58,7 +57,7 @@ abstract class ApplicationBootstrap
|
|||
/**
|
||||
* Config object
|
||||
*
|
||||
* @var Zend_Config
|
||||
* @var Config
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
|
@ -314,12 +313,7 @@ abstract class ApplicationBootstrap
|
|||
$this->moduleManager = new ModuleManager(
|
||||
$this,
|
||||
$this->configDir . '/enabledModules',
|
||||
explode(
|
||||
':',
|
||||
$this->config->global !== null
|
||||
? $this->config->global->get('modulePath', ICINGAWEB_APPDIR . '/../modules')
|
||||
: ICINGAWEB_APPDIR . '/../modules'
|
||||
)
|
||||
explode(':', $this->config->fromSection('global', 'modulePath', ICINGAWEB_APPDIR . '/../modules'))
|
||||
);
|
||||
return $this;
|
||||
}
|
||||
|
@ -362,7 +356,7 @@ abstract class ApplicationBootstrap
|
|||
protected function setupLogging()
|
||||
{
|
||||
Logger::create(
|
||||
new Zend_Config(
|
||||
new Config(
|
||||
array(
|
||||
'log' => 'syslog'
|
||||
)
|
||||
|
@ -384,7 +378,7 @@ abstract class ApplicationBootstrap
|
|||
$this->config = Config::app();
|
||||
} catch (NotReadableError $e) {
|
||||
Logger::error(new IcingaException('Cannot load application configuration. An exception was thrown:', $e));
|
||||
$this->config = new Zend_Config(array());
|
||||
$this->config = new Config();
|
||||
}
|
||||
|
||||
if ($this->config->global !== null) {
|
||||
|
@ -428,9 +422,9 @@ abstract class ApplicationBootstrap
|
|||
*/
|
||||
protected function setupLogger()
|
||||
{
|
||||
if ($this->config->logging !== null) {
|
||||
if (($loggingConfig = $this->config->get('logging')) !== null) {
|
||||
try {
|
||||
Logger::create($this->config->logging);
|
||||
Logger::create($loggingConfig);
|
||||
} catch (ConfigurationError $e) {
|
||||
Logger::error($e);
|
||||
}
|
||||
|
@ -469,7 +463,7 @@ abstract class ApplicationBootstrap
|
|||
if (! $default) {
|
||||
$default = 'UTC';
|
||||
}
|
||||
$timeZoneString = $this->config->global !== null ? $this->config->global->get('timezone', $default) : $default;
|
||||
$timeZoneString = $this->config->fromSection('global', 'timezone', $default);
|
||||
date_default_timezone_set($timeZoneString);
|
||||
DateTimeFactory::setConfig(array('timezone' => $timeZoneString));
|
||||
return $this;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
namespace Icinga\Application;
|
||||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Platform;
|
||||
use Icinga\Application\ApplicationBootstrap;
|
||||
use Icinga\Cli\Params;
|
||||
|
@ -12,7 +13,6 @@ use Icinga\Cli\Screen;
|
|||
use Icinga\Application\Logger;
|
||||
use Icinga\Application\Benchmark;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Zend_Config;
|
||||
|
||||
require_once __DIR__ . '/ApplicationBootstrap.php';
|
||||
|
||||
|
@ -49,7 +49,7 @@ class Cli extends ApplicationBootstrap
|
|||
protected function setupLogging()
|
||||
{
|
||||
Logger::create(
|
||||
new Zend_Config(
|
||||
new Config(
|
||||
array(
|
||||
'level' => Logger::INFO,
|
||||
'log' => 'file',
|
||||
|
|
|
@ -4,14 +4,17 @@
|
|||
|
||||
namespace Icinga\Application;
|
||||
|
||||
use Zend_Config;
|
||||
use Zend_Config_Ini;
|
||||
use Iterator;
|
||||
use Countable;
|
||||
use ArrayAccess;
|
||||
use LogicException;
|
||||
use UnexpectedValueException;
|
||||
use Icinga\Exception\NotReadableError;
|
||||
|
||||
/**
|
||||
* Global registry of application and module configuration.
|
||||
* Container for configuration values and global registry of application and module related configuration.
|
||||
*/
|
||||
class Config extends Zend_Config
|
||||
class Config implements Countable, Iterator, ArrayAccess
|
||||
{
|
||||
/**
|
||||
* Configuration directory where ALL (application and module) configuration is located
|
||||
|
@ -20,13 +23,6 @@ class Config extends Zend_Config
|
|||
*/
|
||||
public static $configDir;
|
||||
|
||||
/**
|
||||
* The INI file this configuration has been loaded from or should be written to
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $configFile;
|
||||
|
||||
/**
|
||||
* Application config instances per file
|
||||
*
|
||||
|
@ -42,95 +38,34 @@ class Config extends Zend_Config
|
|||
protected static $modules = array();
|
||||
|
||||
/**
|
||||
* Load configuration from the given INI file
|
||||
* This config's data
|
||||
*
|
||||
* @param string $file The file to parse
|
||||
*
|
||||
* @throws NotReadableError When the file does not exist or cannot be read
|
||||
* @var array
|
||||
*/
|
||||
public static function fromIni($file)
|
||||
{
|
||||
$config = new static(array(), true);
|
||||
$filepath = realpath($file);
|
||||
|
||||
if ($filepath === false) {
|
||||
$config->setConfigFile($file);
|
||||
} elseif (is_readable($filepath)) {
|
||||
$config->setConfigFile($filepath);
|
||||
$config->merge(new Zend_Config_Ini($filepath));
|
||||
} else {
|
||||
throw new NotReadableError('Cannot read config file "%s". Permission denied', $filepath);
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Retrieve a application config instance
|
||||
* The INI file this configuration has been loaded from or should be written to
|
||||
*
|
||||
* @param string $configname The configuration name (without ini suffix) to read and return
|
||||
* @param bool $fromDisk When set true, the configuration will be read from the disk, even
|
||||
* if it already has been read
|
||||
*
|
||||
* @return Config The configuration object that has been requested
|
||||
* @var string
|
||||
*/
|
||||
public static function app($configname = 'config', $fromDisk = false)
|
||||
{
|
||||
if (!isset(self::$app[$configname]) || $fromDisk) {
|
||||
self::$app[$configname] = Config::fromIni(self::resolvePath($configname . '.ini'));
|
||||
}
|
||||
return self::$app[$configname];
|
||||
}
|
||||
protected $configFile;
|
||||
|
||||
/**
|
||||
* Set module config
|
||||
* Create a new config
|
||||
*
|
||||
* @param string $moduleName
|
||||
* @param string $configName
|
||||
* @param Zend_Config $config
|
||||
* @param array $data The data to initialize the new config with
|
||||
*/
|
||||
public static function setModuleConfig($moduleName, $configName, Zend_Config $config)
|
||||
public function __construct(array $data = array())
|
||||
{
|
||||
self::$modules[$moduleName][$configName] = $config;
|
||||
}
|
||||
$this->data = array();
|
||||
|
||||
/**
|
||||
* Retrieve a module config instance
|
||||
*
|
||||
* @param string $modulename The name of the module to look for configurations
|
||||
* @param string $configname The configuration name (without ini suffix) to read and return
|
||||
* @param string $fromDisk Whether to read the configuration from disk
|
||||
*
|
||||
* @return Config The configuration object that has been requested
|
||||
*/
|
||||
public static function module($modulename, $configname = 'config', $fromDisk = false)
|
||||
{
|
||||
if (!isset(self::$modules[$modulename])) {
|
||||
self::$modules[$modulename] = array();
|
||||
}
|
||||
$moduleConfigs = self::$modules[$modulename];
|
||||
if (!isset($moduleConfigs[$configname]) || $fromDisk) {
|
||||
$moduleConfigs[$configname] = Config::fromIni(
|
||||
self::resolvePath('modules/' . $modulename . '/' . $configname . '.ini')
|
||||
);
|
||||
}
|
||||
return $moduleConfigs[$configname];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve names of accessible sections or properties
|
||||
*
|
||||
* @param $name
|
||||
* @return array
|
||||
*/
|
||||
public function keys($name = null)
|
||||
{
|
||||
if ($name === null) {
|
||||
return array_keys($this->toArray());
|
||||
} elseif ($this->$name === null) {
|
||||
return array();
|
||||
} else {
|
||||
return array_keys($this->$name->toArray());
|
||||
foreach ($data as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$this->data[$key] = new static($value);
|
||||
} else {
|
||||
$this->data[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,13 +93,375 @@ class Config extends Zend_Config
|
|||
}
|
||||
|
||||
/**
|
||||
* Prepend configuration base dir if input is relative
|
||||
* Deep clone this config
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$array = array();
|
||||
foreach ($this->data as $key => $value) {
|
||||
if ($value instanceof self) {
|
||||
$array[$key] = clone $value;
|
||||
} else {
|
||||
$array[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$this->data = $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the count of available sections and properties
|
||||
*
|
||||
* @param string $path Input path
|
||||
* @return string Absolute path
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the current position of $this->data
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
return reset($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the section's or property's value of the current iteration
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
return current($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the position of the current iteration is valid
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return key($this->data) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the section's or property's name of the current iteration
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
return key($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Advance the position of the current iteration and return the new section's or property's value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
return next($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the given section or property is set
|
||||
*
|
||||
* @param string $key The name of the section or property
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($key)
|
||||
{
|
||||
return isset($this->data[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value for the given property or the config for the given section
|
||||
*
|
||||
* @param string $key The name of the property or section
|
||||
*
|
||||
* @return mixed|NULL The value or NULL in case $key does not exist
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
if (array_key_exists($key, $this->data)) {
|
||||
return $this->data[$key];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new property or section
|
||||
*
|
||||
* @param string $key The name of the new property or section
|
||||
* @param mixed $value The value to set for the new property or section
|
||||
*/
|
||||
public function __set($key, $value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
$this->data[$key] = new static($value);
|
||||
} else {
|
||||
$this->data[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given property or section
|
||||
*
|
||||
* @param string $key The property or section to remove
|
||||
*/
|
||||
public function __unset($key)
|
||||
{
|
||||
unset($this->data[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the given section or property is set
|
||||
*
|
||||
* @param string $key The name of the section or property
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetExists($key)
|
||||
{
|
||||
return isset($this->$key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value for the given property or the config for the given section
|
||||
*
|
||||
* @param string $key The name of the property or section
|
||||
*
|
||||
* @return mixed|NULL The value or NULL in case $key does not exist
|
||||
*/
|
||||
public function offsetGet($key)
|
||||
{
|
||||
return $this->$key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new property or section
|
||||
*
|
||||
* @param string $key The name of the new property or section
|
||||
* @param mixed $value The value to set for the new property or section
|
||||
*/
|
||||
public function offsetSet($key, $value)
|
||||
{
|
||||
if ($key === null) {
|
||||
throw new LogicException('Appending values without an explicit key is not supported');
|
||||
}
|
||||
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given property or section
|
||||
*
|
||||
* @param string $key The property or section to remove
|
||||
*/
|
||||
public function offsetUnset($key)
|
||||
{
|
||||
unset($this->$key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this config has any data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmpty()
|
||||
{
|
||||
return $this->count() === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value for the given property or the config for the given section
|
||||
*
|
||||
* @param string $key The name of the property or section
|
||||
* @param mixed $default The value to return in case the property or section is missing
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
$value = $this->$key;
|
||||
if ($default !== null && $value === null) {
|
||||
$value = $default;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all section and property names
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function keys()
|
||||
{
|
||||
return array_keys($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return this config's data as associative array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
$array = array();
|
||||
foreach ($this->data as $key => $value) {
|
||||
if ($value instanceof self) {
|
||||
$array[$key] = $value->toArray();
|
||||
} else {
|
||||
$array[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge the given data with this config
|
||||
*
|
||||
* @param array|Config $data An array or a config
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function merge($data)
|
||||
{
|
||||
if ($data instanceof self) {
|
||||
$data = $data->toArray();
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if (array_key_exists($key, $this->data)) {
|
||||
if (is_array($value)) {
|
||||
if ($this->data[$key] instanceof self) {
|
||||
$this->data[$key]->merge($value);
|
||||
} else {
|
||||
$this->data[$key] = new static($value);
|
||||
}
|
||||
} else {
|
||||
$this->data[$key] = $value;
|
||||
}
|
||||
} else {
|
||||
$this->data[$key] = is_array($value) ? new static($value) : $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value from a section's property
|
||||
*
|
||||
* @param string $section The section where the given property can be found
|
||||
* @param string $key The section's property to fetch the value from
|
||||
* @param mixed $default The value to return in case the section or the property is missing
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws UnexpectedValueException In case the given section does not hold any configuration
|
||||
*/
|
||||
public function fromSection($section, $key, $default = null)
|
||||
{
|
||||
$value = $this->$section;
|
||||
if ($value instanceof self) {
|
||||
$value = $value->$key;
|
||||
} elseif ($value !== null) {
|
||||
throw new UnexpectedValueException(
|
||||
sprintf('Value "%s" is not of type "Config" or a sub-type of it', $value)
|
||||
);
|
||||
}
|
||||
|
||||
if ($default !== null) {
|
||||
$value = $default;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load configuration from the given INI file
|
||||
*
|
||||
* @param string $file The file to parse
|
||||
*
|
||||
* @throws NotReadableError When the file does not exist or cannot be read
|
||||
*/
|
||||
public static function fromIni($file)
|
||||
{
|
||||
$config = new static();
|
||||
|
||||
$filepath = realpath($file);
|
||||
if ($filepath === false) {
|
||||
$config->setConfigFile($file);
|
||||
} elseif (is_readable($filepath)) {
|
||||
$config->setConfigFile($filepath);
|
||||
$config->merge(parse_ini_file($filepath, true));
|
||||
} else {
|
||||
throw new NotReadableError(t('Cannot read config file "%s". Permission denied'), $filepath);
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepend configuration base dir to the given relative path
|
||||
*
|
||||
* @param string $path A relative path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function resolvePath($path)
|
||||
{
|
||||
return self::$configDir . DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a application config
|
||||
*
|
||||
* @param string $configname The configuration name (without ini suffix) to read and return
|
||||
* @param bool $fromDisk When set true, the configuration will be read from disk, even
|
||||
* if it already has been read
|
||||
*
|
||||
* @return Config The requested configuration
|
||||
*/
|
||||
public static function app($configname = 'config', $fromDisk = false)
|
||||
{
|
||||
if (!isset(self::$app[$configname]) || $fromDisk) {
|
||||
self::$app[$configname] = static::fromIni(static::resolvePath($configname . '.ini'));
|
||||
}
|
||||
|
||||
return self::$app[$configname];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a module config
|
||||
*
|
||||
* @param string $modulename The name of the module where to look for the requested configuration
|
||||
* @param string $configname The configuration name (without ini suffix) to read and return
|
||||
* @param string $fromDisk When set true, the configuration will be read from disk, even
|
||||
* if it already has been read
|
||||
*
|
||||
* @return Config The requested configuration
|
||||
*/
|
||||
public static function module($modulename, $configname = 'config', $fromDisk = false)
|
||||
{
|
||||
if (!isset(self::$modules[$modulename])) {
|
||||
self::$modules[$modulename] = array();
|
||||
}
|
||||
|
||||
$moduleConfigs = self::$modules[$modulename];
|
||||
if (!isset($moduleConfigs[$configname]) || $fromDisk) {
|
||||
$moduleConfigs[$configname] = static::fromIni(
|
||||
static::resolvePath('modules/' . $modulename . '/' . $configname . '.ini')
|
||||
);
|
||||
}
|
||||
|
||||
return $moduleConfigs[$configname];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace Icinga\Application;
|
||||
|
||||
use Exception;
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Logger\Writer\FileWriter;
|
||||
use Icinga\Application\Logger\Writer\SyslogWriter;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
|
@ -71,12 +71,12 @@ class Logger
|
|||
/**
|
||||
* Create a new logger object
|
||||
*
|
||||
* @param Zend_Config $config
|
||||
* @param Config $config
|
||||
*
|
||||
* @throws ConfigurationError If the logging configuration directive 'log' is missing or if the logging level is
|
||||
* not defined
|
||||
*/
|
||||
public function __construct(Zend_Config $config)
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
if ($config->log === null) {
|
||||
throw new ConfigurationError('Required logging configuration directive \'log\' missing');
|
||||
|
@ -118,11 +118,11 @@ class Logger
|
|||
/**
|
||||
* Create a new logger object
|
||||
*
|
||||
* @param Zend_Config $config
|
||||
* @param Config $config
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function create(Zend_Config $config)
|
||||
public static function create(Config $config)
|
||||
{
|
||||
static::$instance = new static($config);
|
||||
return static::$instance;
|
||||
|
@ -131,12 +131,12 @@ class Logger
|
|||
/**
|
||||
* Create a log writer
|
||||
*
|
||||
* @param Zend_Config $config The configuration to initialize the writer with
|
||||
* @param Config $config The configuration to initialize the writer with
|
||||
*
|
||||
* @return \Icinga\Application\Logger\LogWriter The requested log writer
|
||||
* @throws ConfigurationError If the requested writer cannot be found
|
||||
*/
|
||||
protected function createWriter(Zend_Config $config)
|
||||
protected function createWriter(Config $config)
|
||||
{
|
||||
$class = 'Icinga\\Application\\Logger\\Writer\\' . ucfirst(strtolower($config->log)) . 'Writer';
|
||||
if (! class_exists($class)) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Icinga\Application\Logger;
|
||||
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
|
||||
/**
|
||||
* Abstract class for writers that write messages to a log
|
||||
|
@ -14,7 +14,7 @@ abstract class LogWriter
|
|||
/**
|
||||
* Create a new log writer initialized with the given configuration
|
||||
*/
|
||||
abstract public function __construct(Zend_Config $config);
|
||||
abstract public function __construct(Config $config);
|
||||
|
||||
/**
|
||||
* Log a message with the given severity
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace Icinga\Application\Logger\Writer;
|
||||
|
||||
use Exception;
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Application\Logger\LogWriter;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
|
@ -26,12 +26,12 @@ class FileWriter extends LogWriter
|
|||
/**
|
||||
* Create a new file log writer
|
||||
*
|
||||
* @param Zend_Config $config
|
||||
* @param Config $config
|
||||
*
|
||||
* @throws ConfigurationError If the configuration directive 'file' is missing or if the path to 'file' does
|
||||
* not exist or if writing to 'file' is not possible
|
||||
*/
|
||||
public function __construct(Zend_Config $config)
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
if ($config->file === null) {
|
||||
throw new ConfigurationError('Required logging configuration directive \'file\' missing');
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Icinga\Application\Logger\Writer;
|
||||
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Application\Logger\LogWriter;
|
||||
|
||||
|
@ -51,9 +51,9 @@ class SyslogWriter extends LogWriter
|
|||
/**
|
||||
* Create a new syslog log writer
|
||||
*
|
||||
* @param Zend_Config $config
|
||||
* @param Config $config
|
||||
*/
|
||||
public function __construct(Zend_Config $config)
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
$this->ident = $config->get('application', 'icingaweb');
|
||||
$this->facility = static::$facilities['user'];
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
namespace Icinga\Application\Modules;
|
||||
|
||||
use Exception;
|
||||
use Zend_Config;
|
||||
use Zend_Controller_Router_Route_Abstract;
|
||||
use Zend_Controller_Router_Route as Route;
|
||||
use Zend_Controller_Router_Route_Regex as RegexRoute;
|
||||
|
@ -243,7 +242,7 @@ class Module
|
|||
if (array_key_exists($name, $this->menuItems)) {
|
||||
$this->menuItems[$name]->setProperties($properties);
|
||||
} else {
|
||||
$this->menuItems[$name] = new Menu($name, new Zend_Config($properties));
|
||||
$this->menuItems[$name] = new Menu($name, new Config($properties));
|
||||
}
|
||||
|
||||
return $this->menuItems[$name];
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace Icinga\Authentication;
|
||||
|
||||
use Iterator;
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
|
||||
|
@ -17,7 +17,7 @@ class AuthChain implements Iterator
|
|||
/**
|
||||
* User backends configuration
|
||||
*
|
||||
* @var Zend_Config
|
||||
* @var Config
|
||||
*/
|
||||
private $config;
|
||||
|
||||
|
@ -31,9 +31,9 @@ class AuthChain implements Iterator
|
|||
/**
|
||||
* Create a new authentication chain from config
|
||||
*
|
||||
* @param Zend_Config $config User backends configuration
|
||||
* @param Config $config User backends configuration
|
||||
*/
|
||||
public function __construct(Zend_Config $config)
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Icinga\Authentication\Backend;
|
||||
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Authentication\UserBackend;
|
||||
use Icinga\User;
|
||||
|
||||
|
@ -23,9 +23,9 @@ class AutoLoginBackend extends UserBackend
|
|||
/**
|
||||
* Create new autologin backend
|
||||
*
|
||||
* @param Zend_Config $config
|
||||
* @param Config $config
|
||||
*/
|
||||
public function __construct(Zend_Config $config)
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
$this->stripUsernameRegexp = $config->get('strip_username_regexp');
|
||||
}
|
||||
|
|
|
@ -82,10 +82,7 @@ class LdapUserBackend extends UserBackend
|
|||
$q = $this->conn->select()->setBase($this->baseDn)->from($this->userClass);
|
||||
$result = $q->fetchRow();
|
||||
} catch (LdapException $e) {
|
||||
throw new AuthenticationException(
|
||||
'Connection not possible: %s',
|
||||
$e->getMessage()
|
||||
);
|
||||
throw new AuthenticationException('Connection not possible.', $e);
|
||||
}
|
||||
|
||||
if (! isset($result)) {
|
||||
|
@ -176,7 +173,7 @@ class LdapUserBackend extends UserBackend
|
|||
} catch (AuthenticationException $e) {
|
||||
// Authentication not possible
|
||||
throw new AuthenticationException(
|
||||
'Authentication against backend "%s" not possible: %s',
|
||||
'Authentication against backend "%s" not possible.',
|
||||
$this->getName(),
|
||||
$e
|
||||
);
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
namespace Icinga\Authentication;
|
||||
|
||||
use Exception;
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Exception\IcingaException;
|
||||
use Icinga\Exception\NotReadableError;
|
||||
|
@ -62,7 +61,7 @@ class Manager
|
|||
$e
|
||||
)
|
||||
);
|
||||
$config = new Zend_Config(array());
|
||||
$config = new Config();
|
||||
}
|
||||
if (($preferencesConfig = $config->preferences) !== null) {
|
||||
try {
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Icinga\Authentication;
|
|||
|
||||
use Countable;
|
||||
use Icinga\Authentication\Backend\AutoLoginBackend;
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Authentication\Backend\DbUserBackend;
|
||||
use Icinga\Authentication\Backend\LdapUserBackend;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
|
@ -45,7 +45,7 @@ abstract class UserBackend implements Countable
|
|||
return $this->name;
|
||||
}
|
||||
|
||||
public static function create($name, Zend_Config $backendConfig)
|
||||
public static function create($name, Config $backendConfig)
|
||||
{
|
||||
if ($backendConfig->name !== null) {
|
||||
$name = $backendConfig->name;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Icinga\Authentication;
|
||||
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Authentication\Backend\DbUserGroupBackend;
|
||||
use Icinga\Authentication\Backend\IniUserGroupBackend;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
|
@ -50,13 +50,13 @@ abstract class UserGroupBackend
|
|||
/**
|
||||
* Create a user group backend
|
||||
*
|
||||
* @param string $name
|
||||
* @param Zend_Config $backendConfig
|
||||
* @param string $name
|
||||
* @param Config $backendConfig
|
||||
*
|
||||
* @return DbUserGroupBackend|IniUserGroupBackend
|
||||
* @throws ConfigurationError If the backend configuration is invalid
|
||||
*/
|
||||
public static function create($name, Zend_Config $backendConfig)
|
||||
public static function create($name, Config $backendConfig)
|
||||
{
|
||||
if ($backendConfig->name !== null) {
|
||||
$name = $backendConfig->name;
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
|
||||
namespace Icinga\Data\Db;
|
||||
|
||||
use PDO;
|
||||
use Zend_Db;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Benchmark;
|
||||
use Icinga\Data\Db\DbQuery;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Data\Selectable;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use PDO;
|
||||
use Zend_Config;
|
||||
use Zend_Db;
|
||||
|
||||
/**
|
||||
* Encapsulate database connections and query creation
|
||||
|
@ -21,7 +21,7 @@ class DbConnection implements Selectable
|
|||
/**
|
||||
* Connection config
|
||||
*
|
||||
* @var Zend_Config
|
||||
* @var Config
|
||||
*/
|
||||
private $config;
|
||||
|
||||
|
@ -59,9 +59,9 @@ class DbConnection implements Selectable
|
|||
/**
|
||||
* Create a new connection object
|
||||
*
|
||||
* @param Zend_Config $config
|
||||
* @param Config $config
|
||||
*/
|
||||
public function __construct(Zend_Config $config = null)
|
||||
public function __construct(Config $config = null)
|
||||
{
|
||||
$this->config = $config;
|
||||
if (isset($config->prefix)) {
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
namespace Icinga\Data;
|
||||
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Util\ConfigAwareFactory;
|
||||
|
@ -22,14 +21,14 @@ class ResourceFactory implements ConfigAwareFactory
|
|||
/**
|
||||
* Resource configuration
|
||||
*
|
||||
* @var Zend_Config
|
||||
* @var Config
|
||||
*/
|
||||
private static $resources;
|
||||
|
||||
/**
|
||||
* Set resource configurations
|
||||
*
|
||||
* @param Zend_Config $config
|
||||
* @param Config $config
|
||||
*/
|
||||
public static function setConfig($config)
|
||||
{
|
||||
|
@ -41,7 +40,7 @@ class ResourceFactory implements ConfigAwareFactory
|
|||
*
|
||||
* @param $resourceName String The resource's name
|
||||
*
|
||||
* @return Zend_Config The configuration of the resource
|
||||
* @return Config The configuration of the resource
|
||||
*
|
||||
* @throws ConfigurationError
|
||||
*/
|
||||
|
@ -62,7 +61,7 @@ class ResourceFactory implements ConfigAwareFactory
|
|||
*
|
||||
* @param String|null $type Fetch only resources that have the given type.
|
||||
*
|
||||
* @return Zend_Config The configuration containing all resources
|
||||
* @return Config The configuration containing all resources
|
||||
*/
|
||||
public static function getResourceConfigs($type = null)
|
||||
{
|
||||
|
@ -76,7 +75,7 @@ class ResourceFactory implements ConfigAwareFactory
|
|||
$resources[$name] = $resource;
|
||||
}
|
||||
}
|
||||
return new Zend_Config($resources);
|
||||
return new Config($resources);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,13 +99,13 @@ class ResourceFactory implements ConfigAwareFactory
|
|||
* NOTE: The factory does not test if the given configuration is valid and the resource is accessible, this
|
||||
* depends entirely on the implementation of the returned resource.
|
||||
*
|
||||
* @param Zend_Config $config The configuration for the created resource.
|
||||
* @param Config $config The configuration for the created resource.
|
||||
*
|
||||
* @return DbConnection|LdapConnection|LivestatusConnection An object that can be used to access
|
||||
* the given resource. The returned class depends on the configuration property 'type'.
|
||||
* @throws ConfigurationError When an unsupported type is given
|
||||
*/
|
||||
public static function createResource(Zend_Config $config)
|
||||
public static function createResource(Config $config)
|
||||
{
|
||||
switch (strtolower($config->type)) {
|
||||
case 'db':
|
||||
|
|
|
@ -8,6 +8,7 @@ use Zend_Config;
|
|||
use Zend_Config_Ini;
|
||||
use Zend_Config_Exception;
|
||||
use Zend_Config_Writer_FileAbstract;
|
||||
use Icinga\Application\Config;
|
||||
|
||||
/**
|
||||
* A INI file adapter that respects the file structure and the comments of already existing ini files
|
||||
|
@ -41,6 +42,12 @@ class IniWriter extends Zend_Config_Writer_FileAbstract
|
|||
*/
|
||||
public function __construct(array $options = null)
|
||||
{
|
||||
if (isset($options['config']) && $options['config'] instanceof Config) {
|
||||
// As this class inherits from Zend_Config_Writer_FileAbstract we must
|
||||
// not pass the config directly as it needs to be of type Zend_Config
|
||||
$options['config'] = new Zend_Config($options['config']->toArray(), true);
|
||||
}
|
||||
|
||||
$this->options = $options;
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
namespace Icinga\Protocol\File;
|
||||
|
||||
use Icinga\Data\Selectable;
|
||||
use Countable;
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Data\Selectable;
|
||||
|
||||
/**
|
||||
* Read file line by line
|
||||
|
@ -30,11 +30,11 @@ class FileReader implements Selectable, Countable
|
|||
/**
|
||||
* Create a new reader
|
||||
*
|
||||
* @param Zend_Config $config
|
||||
* @param Config $config
|
||||
*
|
||||
* @throws FileReaderException If a required $config directive (filename or fields) is missing
|
||||
*/
|
||||
public function __construct(Zend_Config $config)
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
foreach (array('filename', 'fields') as $key) {
|
||||
if (isset($config->{$key})) {
|
||||
|
|
|
@ -8,7 +8,6 @@ use Icinga\Protocol\Ldap\Exception as LdapException;
|
|||
use Icinga\Application\Platform;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Logger;
|
||||
use Zend_Config;
|
||||
|
||||
/**
|
||||
* Backend class managing all the LDAP stuff for you.
|
||||
|
@ -101,9 +100,9 @@ class Connection
|
|||
*
|
||||
* TODO: Allow to pass port and SSL options
|
||||
*
|
||||
* @param Zend_Config $config
|
||||
* @param Config $config
|
||||
*/
|
||||
public function __construct(Zend_Config $config)
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
$this->hostname = $config->hostname;
|
||||
$this->bind_dn = $config->bind_dn;
|
||||
|
@ -336,9 +335,9 @@ class Connection
|
|||
|
||||
public function testCredentials($username, $password)
|
||||
{
|
||||
$ds = $this->prepareNewConnection();
|
||||
$this->connect();
|
||||
|
||||
$r = @ldap_bind($ds, $username, $password);
|
||||
$r = @ldap_bind($this->ds, $username, $password);
|
||||
if ($r) {
|
||||
Logger::debug(
|
||||
'Successfully tested LDAP credentials (%s / %s)',
|
||||
|
@ -351,7 +350,7 @@ class Connection
|
|||
'Testing LDAP credentials (%s / %s) failed: %s',
|
||||
$username,
|
||||
'***',
|
||||
ldap_error($ds)
|
||||
ldap_error($this->ds)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
@ -364,7 +363,7 @@ class Connection
|
|||
*/
|
||||
protected function getConfigDir($sub = null)
|
||||
{
|
||||
$dir = Config::getInstance()->getConfigDir() . '/ldap';
|
||||
$dir = Config::$configDir . '/ldap';
|
||||
if ($sub !== null) {
|
||||
$dir .= '/' . $sub;
|
||||
}
|
||||
|
@ -388,7 +387,19 @@ class Connection
|
|||
}
|
||||
|
||||
$ds = ldap_connect($this->hostname, $this->port);
|
||||
list($cap, $namingContexts) = $this->discoverCapabilities($ds);
|
||||
try {
|
||||
$capabilities = $this->discoverCapabilities($ds);
|
||||
list($cap, $namingContexts) = $capabilities;
|
||||
} catch (LdapException $e) {
|
||||
|
||||
// discovery failed, guess defaults
|
||||
$cap = (object) array(
|
||||
'supports_ldapv3' => true,
|
||||
'supports_starttls' => false,
|
||||
'msCapabilities' => array()
|
||||
);
|
||||
$namingContexts = null;
|
||||
}
|
||||
$this->capabilities = $cap;
|
||||
$this->namingContexts = $namingContexts;
|
||||
|
||||
|
@ -626,7 +637,8 @@ class Connection
|
|||
if (! $result) {
|
||||
throw new LdapException(
|
||||
sprintf(
|
||||
'Capability query failed (%s:%d): %s',
|
||||
'Capability query failed (%s:%d): %s. Check if hostname and port of the ldap resource are correct '
|
||||
. ' and if anonymous access is permitted.',
|
||||
$this->hostname,
|
||||
$this->port,
|
||||
ldap_error($ds)
|
||||
|
@ -634,6 +646,16 @@ class Connection
|
|||
);
|
||||
}
|
||||
$entry = ldap_first_entry($ds, $result);
|
||||
if ($entry === false) {
|
||||
throw new LdapException(
|
||||
sprintf(
|
||||
'Capabilities not available (%s:%d): %s. Discovery of root DSE probably not permitted.',
|
||||
$this->hostname,
|
||||
$this->port,
|
||||
ldap_error($ds)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$cap = (object) array(
|
||||
'supports_ldapv3' => false,
|
||||
|
@ -641,10 +663,6 @@ class Connection
|
|||
'msCapabilities' => array()
|
||||
);
|
||||
|
||||
if ($entry === false) {
|
||||
// TODO: Is it OK to have no capabilities?
|
||||
return false;
|
||||
}
|
||||
$ldapAttributes = ldap_get_attributes($ds, $entry);
|
||||
$result = $this->cleanupAttributes($ldapAttributes);
|
||||
$cap->supports_ldapv3 = $this->hasCapabilityLdapV3($result);
|
||||
|
|
|
@ -24,9 +24,9 @@ namespace Icinga\Test {
|
|||
use Exception;
|
||||
use RuntimeException;
|
||||
use Mockery;
|
||||
use Zend_Config;
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Util\DateTimeFactory;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Data\Db\DbConnection;
|
||||
|
@ -191,17 +191,17 @@ namespace Icinga\Test {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create Zend_Config for database configuration
|
||||
* Create Config for database configuration
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Zend_Config
|
||||
* @return Config
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function createDbConfigFor($name)
|
||||
{
|
||||
if (array_key_exists($name, self::$dbConfiguration)) {
|
||||
return new Zend_Config(self::$dbConfiguration[$name]);
|
||||
return new Config(self::$dbConfiguration[$name]);
|
||||
}
|
||||
|
||||
throw new RuntimeException('Configuration for database type not available: ' . $name);
|
||||
|
|
|
@ -4,13 +4,12 @@
|
|||
|
||||
namespace Icinga\User\Preferences;
|
||||
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\User;
|
||||
use Icinga\User\Preferences;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Data\Db\DbConnection;
|
||||
use Icinga\Application\Config as IcingaConfig;
|
||||
|
||||
/**
|
||||
* Preferences store factory
|
||||
|
@ -19,13 +18,13 @@ use Icinga\Application\Config as IcingaConfig;
|
|||
* <code>
|
||||
* <?php
|
||||
*
|
||||
* use Zend_Config;
|
||||
* use Icinga\Application\Config;
|
||||
* use Icinga\User\Preferences;
|
||||
* use Icinga\User\Preferences\PreferencesStore;
|
||||
*
|
||||
* // Create a INI store
|
||||
* $store = PreferencesStore::create(
|
||||
* new Zend_Config(
|
||||
* new Config(
|
||||
* 'type' => 'ini',
|
||||
* 'config_path' => '/path/to/preferences'
|
||||
* ),
|
||||
|
@ -42,7 +41,7 @@ abstract class PreferencesStore
|
|||
/**
|
||||
* Store config
|
||||
*
|
||||
* @var Zend_Config
|
||||
* @var Config
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
|
@ -56,10 +55,10 @@ abstract class PreferencesStore
|
|||
/**
|
||||
* Create a new store
|
||||
*
|
||||
* @param Zend_Config $config The config for this adapter
|
||||
* @param User $user The user to which these preferences belong
|
||||
* @param Config $config The config for this adapter
|
||||
* @param User $user The user to which these preferences belong
|
||||
*/
|
||||
public function __construct(Zend_Config $config, User $user)
|
||||
public function __construct(Config $config, User $user)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->user = $user;
|
||||
|
@ -69,7 +68,7 @@ abstract class PreferencesStore
|
|||
/**
|
||||
* Getter for the store config
|
||||
*
|
||||
* @return Zend_Config
|
||||
* @return Config
|
||||
*/
|
||||
public function getStoreConfig()
|
||||
{
|
||||
|
@ -108,14 +107,14 @@ abstract class PreferencesStore
|
|||
/**
|
||||
* Create preferences storage adapter from config
|
||||
*
|
||||
* @param Zend_Config $config The config for the adapter
|
||||
* @param User $user The user to which these preferences belong
|
||||
* @param Config $config The config for the adapter
|
||||
* @param User $user The user to which these preferences belong
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @throws ConfigurationError When the configuration defines an invalid storage type
|
||||
*/
|
||||
public static function create(Zend_Config $config, User $user)
|
||||
public static function create(Config $config, User $user)
|
||||
{
|
||||
if (($type = $config->type) === null) {
|
||||
throw new ConfigurationError(
|
||||
|
@ -133,7 +132,7 @@ abstract class PreferencesStore
|
|||
}
|
||||
|
||||
if ($type === 'Ini') {
|
||||
$config->location = IcingaConfig::resolvePath('preferences');
|
||||
$config->location = Config::resolvePath('preferences');
|
||||
} elseif ($type === 'Db') {
|
||||
$config->connection = new DbConnection(ResourceFactory::getResourceConfig($config->resource));
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Icinga\User\Preferences\Store;
|
||||
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Exception\NotReadableError;
|
||||
use Icinga\Exception\NotWritableError;
|
||||
use Icinga\File\Ini\IniWriter;
|
||||
|
@ -116,7 +116,7 @@ class IniStore extends PreferencesStore
|
|||
|
||||
$this->writer = new IniWriter(
|
||||
array(
|
||||
'config' => new Zend_Config($this->preferences),
|
||||
'config' => new Config($this->preferences),
|
||||
'filename' => $this->preferencesFile
|
||||
)
|
||||
);
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
namespace Icinga\Web\Form\Validator;
|
||||
|
||||
use Zend_Validate_Abstract;
|
||||
use Icinga\Application\Config as IcingaConfig;
|
||||
|
||||
/**
|
||||
* Validator that interprets the value as a path and checks if it's writable
|
||||
|
|
|
@ -6,7 +6,6 @@ namespace Icinga\Web;
|
|||
|
||||
use Icinga\Web\Menu\MenuItemRenderer;
|
||||
use RecursiveIterator;
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Application\Logger;
|
||||
|
@ -79,10 +78,10 @@ class Menu implements RecursiveIterator
|
|||
/**
|
||||
* Create a new menu
|
||||
*
|
||||
* @param int $id The id of this menu
|
||||
* @param Zend_Config $config The configuration for this menu
|
||||
* @param int $id The id of this menu
|
||||
* @param Config $config The configuration for this menu
|
||||
*/
|
||||
public function __construct($id, Zend_Config $config = null, Menu $parent = null)
|
||||
public function __construct($id, Config $config = null, Menu $parent = null)
|
||||
{
|
||||
$this->id = $id;
|
||||
if ($parent !== null) {
|
||||
|
@ -94,7 +93,7 @@ class Menu implements RecursiveIterator
|
|||
/**
|
||||
* Set all given properties
|
||||
*
|
||||
* @param array|Zend_Config $props Property list
|
||||
* @param array|Config $props Property list
|
||||
*/
|
||||
public function setProperties($props = null)
|
||||
{
|
||||
|
@ -415,11 +414,11 @@ class Menu implements RecursiveIterator
|
|||
* Add a sub menu to this menu
|
||||
*
|
||||
* @param string $id The id of the menu to add
|
||||
* @param Zend_Config $itemConfig The config with which to initialize the menu
|
||||
* @param Config $itemConfig The config with which to initialize the menu
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function addSubMenu($id, Zend_Config $menuConfig = null)
|
||||
public function addSubMenu($id, Config $menuConfig = null)
|
||||
{
|
||||
if (false === ($pos = strpos($id, '.'))) {
|
||||
$subMenu = new self($id, $menuConfig, $this);
|
||||
|
@ -509,7 +508,7 @@ class Menu implements RecursiveIterator
|
|||
*/
|
||||
public function add($name, $config = array())
|
||||
{
|
||||
return $this->addSubMenu($name, new Zend_Config($config));
|
||||
return $this->addSubMenu($name, new Config($config));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace Icinga\Web\Widget;
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Application\Config as IcingaConfig;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Web\Widget\Dashboard\Pane;
|
||||
|
@ -26,7 +26,7 @@ class Dashboard extends AbstractWidget
|
|||
/**
|
||||
* The configuration containing information about this dashboard
|
||||
*
|
||||
* @var IcingaConfig;
|
||||
* @var Config;
|
||||
*/
|
||||
private $config;
|
||||
|
||||
|
@ -140,11 +140,11 @@ class Dashboard extends AbstractWidget
|
|||
/**
|
||||
* Populate this dashboard via the given configuration file
|
||||
*
|
||||
* @param IcingaConfig $config The configuration file to populate this dashboard with
|
||||
* @param Config $config The configuration file to populate this dashboard with
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function readConfig(IcingaConfig $config)
|
||||
public function readConfig(Config $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->panes = array();
|
||||
|
|
|
@ -4,16 +4,12 @@
|
|||
|
||||
namespace Icinga\Web\Widget\Dashboard;
|
||||
|
||||
use Icinga\Exception\IcingaException;
|
||||
use Icinga\Util\Dimension;
|
||||
use Zend_Form_Element_Button;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Web\Widget\AbstractWidget;
|
||||
use Icinga\Web\View;
|
||||
use Zend_Config;
|
||||
use Zend_Form_Element_Submit;
|
||||
use Zend_Form_Element_Button;
|
||||
use Exception;
|
||||
use Icinga\Exception\IcingaException;
|
||||
|
||||
/**
|
||||
* A dashboard pane component
|
||||
|
@ -218,13 +214,13 @@ EOD;
|
|||
/**
|
||||
* Create a @see Component instance from the given Zend config, using the provided title
|
||||
*
|
||||
* @param $title The title for this component
|
||||
* @param Zend_Config $config The configuration defining url, parameters, height, width, etc.
|
||||
* @param Pane $pane The pane this component belongs to
|
||||
* @param $title The title for this component
|
||||
* @param Config $config The configuration defining url, parameters, height, width, etc.
|
||||
* @param Pane $pane The pane this component belongs to
|
||||
*
|
||||
* @return Component A newly created Component for use in the Dashboard
|
||||
* @return Component A newly created Component for use in the Dashboard
|
||||
*/
|
||||
public static function fromIni($title, Zend_Config $config, Pane $pane)
|
||||
public static function fromIni($title, Config $config, Pane $pane)
|
||||
{
|
||||
$height = null;
|
||||
$width = null;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Icinga\Web\Widget\Dashboard;
|
||||
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Widget\AbstractWidget;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
|
@ -253,11 +253,11 @@ class Pane extends AbstractWidget
|
|||
* Create a new pane with the title $title from the given configuration
|
||||
*
|
||||
* @param $title The title for this pane
|
||||
* @param Zend_Config $config The configuration to use for setup
|
||||
* @param Config $config The configuration to use for setup
|
||||
*
|
||||
* @return Pane
|
||||
*/
|
||||
public static function fromIni($title, Zend_Config $config)
|
||||
public static function fromIni($title, Config $config)
|
||||
{
|
||||
$pane = new Pane($title);
|
||||
if ($config->get('title', false)) {
|
||||
|
|
|
@ -9,17 +9,14 @@ use Icinga\Module\Monitoring\Form\Command\DisableNotificationWithExpireForm;
|
|||
use Icinga\Module\Monitoring\Form\Command\SingleArgumentCommandForm;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
use Icinga\Web\Notification;
|
||||
use Icinga\Module\Monitoring\Controller;
|
||||
use Icinga\Protocol\Commandpipe\CommandPipe;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Exception\MissingParameterException;
|
||||
use Icinga\Module\Monitoring\Backend;
|
||||
use Icinga\Module\Monitoring\Form\Command\AcknowledgeForm;
|
||||
use Icinga\Module\Monitoring\Form\Command\CommentForm;
|
||||
use Icinga\Module\Monitoring\Form\Command\CommandForm;
|
||||
use Icinga\Module\Monitoring\Form\Command\CommandWithIdentifierForm;
|
||||
use Icinga\Module\Monitoring\Form\Command\CustomNotificationForm;
|
||||
use Icinga\Module\Monitoring\Form\Command\DelayNotificationForm;
|
||||
use Icinga\Module\Monitoring\Form\Command\RescheduleNextCheckForm;
|
||||
|
|
|
@ -296,7 +296,7 @@ class Monitoring_ListController extends Controller
|
|||
->order('downtime_scheduled_start', 'DESC');
|
||||
|
||||
$this->applyFilters($query);
|
||||
$this->view->downtimes = $query->paginate();
|
||||
|
||||
$this->setupSortControl(array(
|
||||
'downtime_is_in_effect' => $this->translate('Is In Effect'),
|
||||
'downtime_host' => $this->translate('Host / Service'),
|
||||
|
@ -308,6 +308,8 @@ class Monitoring_ListController extends Controller
|
|||
'downtime_scheduled_end' => $this->translate('Scheduled End'),
|
||||
'downtime_duration' => $this->translate('Duration'),
|
||||
));
|
||||
|
||||
$this->view->downtimes = $query->paginate();
|
||||
$this->view->delDowntimeForm = new DeleteDowntimeCommandForm();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,16 +4,13 @@
|
|||
|
||||
use \DateTime;
|
||||
use \DateInterval;
|
||||
use \Zend_Config;
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Util\Format;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Util\DateTimeFactory;
|
||||
use Icinga\Module\Monitoring\Controller;
|
||||
use Icinga\Module\Monitoring\Timeline\TimeLine;
|
||||
use Icinga\Module\Monitoring\Timeline\TimeRange;
|
||||
use Icinga\Module\Monitoring\Web\Widget\SelectBox;
|
||||
use Icinga\Module\Monitoring\DataView\EventHistory as EventHistoryView;
|
||||
|
||||
class Monitoring_TimelineController extends Controller
|
||||
{
|
||||
|
@ -257,22 +254,6 @@ class Monitoring_TimelineController extends Controller
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the application's global configuration or an empty one
|
||||
*
|
||||
* @return Zend_Config
|
||||
*/
|
||||
private function getGlobalConfiguration()
|
||||
{
|
||||
$globalConfig = Config::app()->global;
|
||||
|
||||
if ($globalConfig === null) {
|
||||
$globalConfig = new Zend_Config(array());
|
||||
}
|
||||
|
||||
return $globalConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user's preferred time format or the application's default
|
||||
*
|
||||
|
|
|
@ -225,15 +225,31 @@ class BackendConfigForm extends ConfigForm
|
|||
'value' => $resourceType
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
|
||||
$resourceElement = $this->createElement(
|
||||
'select',
|
||||
'resource',
|
||||
array(
|
||||
'required' => true,
|
||||
'label' => mt('monitoring', 'Resource'),
|
||||
'description' => mt('monitoring', 'The resource to use'),
|
||||
'multiOptions' => $this->resources[$resourceType]
|
||||
'multiOptions' => $this->resources[$resourceType],
|
||||
'autosubmit' => true
|
||||
)
|
||||
);
|
||||
|
||||
$resourceName = (isset($formData['resource'])) ? $formData['resource'] : $this->getValue('resource');
|
||||
if ($resourceElement) {
|
||||
$resourceElement->getDecorator('Description')->setEscape(false);
|
||||
$link = sprintf(
|
||||
'<a href="%s" data-base-target="_main">%s</a>',
|
||||
$this->getView()->href('/icingaweb/config/editresource', array('resource' => $resourceName)),
|
||||
mt('monitoring', 'Show resource configuration')
|
||||
);
|
||||
$resourceElement->setDescription($resourceElement->getDescription() . ' (' . $link . ')');
|
||||
}
|
||||
|
||||
$this->addElement($resourceElement);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
class Zend_View_Helper_Customvar extends Zend_View_Helper_Abstract
|
||||
{
|
||||
/**
|
||||
* Create dispatch instance
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function checkPerformance()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function customvar($struct)
|
||||
{
|
||||
if (is_string($struct) || is_int($struct) || is_float($struct)) {
|
||||
return $this->view->escape((string) $struct);
|
||||
} elseif (is_array($struct)) {
|
||||
return $this->renderArray($struct);
|
||||
} elseif (is_object($struct)) {
|
||||
return $this->renderObject($struct);
|
||||
}
|
||||
}
|
||||
|
||||
protected function renderArray($array)
|
||||
{
|
||||
if (empty($array)) {
|
||||
return '[]';
|
||||
}
|
||||
$out = "<ul>\n";
|
||||
foreach ($array as $val) {
|
||||
$out .= '<li>' . $this->customvar($val) . "</li>\n";
|
||||
}
|
||||
return $out . "</ul>\n";
|
||||
}
|
||||
|
||||
protected function renderObject($object)
|
||||
{
|
||||
if (empty($object)) {
|
||||
return '{}';
|
||||
}
|
||||
$out = "{<ul>\n";
|
||||
foreach ($object as $key => $val) {
|
||||
$out .= '<li>'
|
||||
. $this->view->escape($key)
|
||||
. ' => '
|
||||
. $this->customvar($val)
|
||||
. "</li>\n";
|
||||
}
|
||||
return $out . "</ul>}";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3,6 +3,9 @@
|
|||
<?= $this->tabs->render($this); ?>
|
||||
<div style="margin: 1em" class="dontprint">
|
||||
<?= $this->translate('Sort by'); ?> <?= $this->sortControl->render($this); ?>
|
||||
<?php if (! $this->filterEditor): ?>
|
||||
<?= $this->filterPreview ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?= $this->widget('limiter', array('url' => $this->url, 'max' => $downtimes->count())); ?>
|
||||
<?= $this->paginationControl($downtimes, null, null, array('preserve' => $this->preserve)); ?>
|
||||
|
@ -10,6 +13,7 @@
|
|||
<?php endif ?>
|
||||
|
||||
<div class="content">
|
||||
<?= $this->filterEditor ?>
|
||||
<?php if (empty($downtimes)): ?>
|
||||
<?= $this->translate('No downtimes matching the filter'); ?>
|
||||
</div>
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
<?php
|
||||
|
||||
foreach ($object->customvars as $name => $value) {
|
||||
|
||||
printf(
|
||||
"<tr><th>%s</th><td>%s</td></tr>\n",
|
||||
'<tr><th>%s</th><td class="customvar">%s</td></tr>' . "\n",
|
||||
$this->escape($name),
|
||||
$this->escape($value)
|
||||
$this->customvar($value)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ use Icinga\Data\Selectable;
|
|||
use Icinga\Data\Queryable;
|
||||
use Icinga\Data\ConnectionInterface;
|
||||
|
||||
use Icinga\Application\Config as IcingaConfig;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
|
||||
|
@ -69,7 +69,7 @@ class Backend implements Selectable, Queryable, ConnectionInterface
|
|||
*/
|
||||
public static function createBackend($backendName = null)
|
||||
{
|
||||
$config = IcingaConfig::module('monitoring', 'backends');
|
||||
$config = Config::module('monitoring', 'backends');
|
||||
if ($config->count() === 0) {
|
||||
throw new ConfigurationError(mt('monitoring', 'No backend has been configured'));
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ class CustomvarQuery extends IdoQuery
|
|||
'customvars' => array(
|
||||
'varname' => 'cvs.varname',
|
||||
'varvalue' => 'cvs.varvalue',
|
||||
'is_json' => 'cvs.is_json',
|
||||
),
|
||||
'objects' => array(
|
||||
'host' => 'cvo.name1 COLLATE latin1_general_ci',
|
||||
|
@ -37,6 +38,10 @@ class CustomvarQuery extends IdoQuery
|
|||
|
||||
protected function joinBaseTables()
|
||||
{
|
||||
if (version_compare($this->getIdoVersion(), '1.12.0', '<')) {
|
||||
$this->columnMap['customvars']['is_json'] = '(0)';
|
||||
}
|
||||
|
||||
$this->select->from(
|
||||
array('cvs' => $this->prefix . 'customvariablestatus'),
|
||||
array()
|
||||
|
|
|
@ -16,6 +16,7 @@ class DowntimeQuery extends IdoQuery
|
|||
protected $columnMap = array(
|
||||
'downtime' => array(
|
||||
'downtime_author' => 'sd.author_name',
|
||||
'author' => 'sd.author_name',
|
||||
'downtime_comment' => 'sd.comment_data',
|
||||
'downtime_entry_time' => 'UNIX_TIMESTAMP(sd.entry_time)',
|
||||
'downtime_is_fixed' => 'sd.is_fixed',
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\Command\Transport;
|
||||
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
|
||||
|
@ -45,12 +44,12 @@ abstract class CommandTransport
|
|||
/**
|
||||
* Create a transport from config
|
||||
*
|
||||
* @param Zend_Config $config
|
||||
* @param Config $config
|
||||
*
|
||||
* @return LocalCommandFile|RemoteCommandFile
|
||||
* @throws ConfigurationError
|
||||
*/
|
||||
public static function fromConfig(Zend_Config $config)
|
||||
public static function fromConfig(Config $config)
|
||||
{
|
||||
switch (strtolower($config->transport)) {
|
||||
case RemoteCommandFile::TRANSPORT:
|
||||
|
|
|
@ -19,6 +19,7 @@ class Customvar extends DataView
|
|||
return array(
|
||||
'varname',
|
||||
'varvalue',
|
||||
'is_json',
|
||||
'object_type'
|
||||
);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ class Downtime extends DataView
|
|||
return array(
|
||||
'downtime_objecttype',
|
||||
'downtime_author',
|
||||
'author',
|
||||
'downtime_comment',
|
||||
'downtime_entry_time',
|
||||
'downtime_is_fixed',
|
||||
|
|
|
@ -283,7 +283,8 @@ abstract class MonitoredObject
|
|||
|
||||
$query = $this->backend->select()->from('customvar', array(
|
||||
'varname',
|
||||
'varvalue'
|
||||
'varvalue',
|
||||
'is_json'
|
||||
))
|
||||
->where('object_type', $this->type)
|
||||
->where('host_name', $this->host_name);
|
||||
|
@ -293,13 +294,16 @@ abstract class MonitoredObject
|
|||
|
||||
$this->customvars = array();
|
||||
|
||||
$customvars = $query->getQuery()->fetchPairs();
|
||||
foreach ($customvars as $name => $value) {
|
||||
$name = ucwords(str_replace('_', ' ', strtolower($name)));
|
||||
if ($blacklistPattern && preg_match($blacklistPattern, $name)) {
|
||||
$value = '***';
|
||||
$customvars = $query->getQuery()->fetchAll();
|
||||
foreach ($customvars as $name => $cv) {
|
||||
$name = ucwords(str_replace('_', ' ', strtolower($cv->varname)));
|
||||
if ($blacklistPattern && preg_match($blacklistPattern, $cv->varname)) {
|
||||
$this->customvars[$name] = '***';
|
||||
} elseif ($cv->is_json) {
|
||||
$this->customvars[$name] = json_decode($cv->varvalue);
|
||||
} else {
|
||||
$this->customvars[$name] = $cv->varvalue;
|
||||
}
|
||||
$this->customvars[$name] = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
|
@ -158,3 +158,11 @@ form.instance-features span.description, form.object-features span.description {
|
|||
margin: 0 10px 0 0;
|
||||
border-spacing: 10px 10px;
|
||||
}
|
||||
|
||||
table.avp .customvar ul {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
padding-left: 1.5em;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,16 @@ use Icinga\Application\Config;
|
|||
use Icinga\Module\Monitoring\Backend;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
use Mockery;
|
||||
use Zend_Config;
|
||||
|
||||
|
||||
class ConfigWithSetModuleConfig extends Config
|
||||
{
|
||||
public static function setModuleConfig($moduleName, $configName, $config)
|
||||
{
|
||||
static::$modules[$moduleName][$configName] = $config;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Bug7043Test extends BaseTestCase
|
||||
{
|
||||
|
@ -36,7 +45,7 @@ class Bug7043Test extends BaseTestCase
|
|||
->getMock()
|
||||
);
|
||||
|
||||
Config::setModuleConfig('monitoring', 'backends', new Zend_Config(array(
|
||||
ConfigWithSetModuleConfig::setModuleConfig('monitoring', 'backends', new Config(array(
|
||||
'backendName' => array(
|
||||
'type' => 'ido',
|
||||
'resource' => 'ido'
|
||||
|
|
|
@ -11,6 +11,7 @@ require_once realpath(dirname(__FILE__) . '/../../../../bootstrap.php');
|
|||
use Mockery;
|
||||
use Zend_Config;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Form\Config\Authentication\LdapBackendForm;
|
||||
use Icinga\Exception\AuthenticationException;
|
||||
|
||||
|
@ -70,6 +71,6 @@ class LdapBackendFormTest extends BaseTestCase
|
|||
->shouldReceive('createResource')
|
||||
->andReturn(Mockery::mock('Icinga\Protocol\Ldap\Connection'))
|
||||
->shouldReceive('getResourceConfig')
|
||||
->andReturn(new Zend_Config(array()));
|
||||
->andReturn(new Config());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ class DbResourceFormTest extends BaseTestCase
|
|||
{
|
||||
Mockery::mock('alias:Icinga\Data\ResourceFactory')
|
||||
->shouldReceive('createResource')
|
||||
->with(Mockery::type('\Zend_Config'))
|
||||
->with(Mockery::type('Icinga\Application\Config'))
|
||||
->andReturn($resourceMock);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ class LdapResourceFormTest extends BaseTestCase
|
|||
{
|
||||
Mockery::mock('alias:Icinga\Data\ResourceFactory')
|
||||
->shouldReceive('createResource')
|
||||
->with(Mockery::type('\Zend_Config'))
|
||||
->with(Mockery::type('Icinga\Application\Config'))
|
||||
->andReturn($resourceMock);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ class LivestatusResourceFormTest extends BaseTestCase
|
|||
{
|
||||
Mockery::mock('alias:Icinga\Data\ResourceFactory')
|
||||
->shouldReceive('createResource')
|
||||
->with(Mockery::type('\Zend_Config'))
|
||||
->with(Mockery::type('Icinga\Application\Config'))
|
||||
->andReturn($resourceMock);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace Tests\Icinga\Application;
|
||||
|
||||
use Icinga\Test\BaseTestCase;
|
||||
use Icinga\Application\Config as IcingaConfig;
|
||||
use Icinga\Application\Config;
|
||||
|
||||
class ConfigTest extends BaseTestCase
|
||||
{
|
||||
|
@ -15,8 +15,8 @@ class ConfigTest extends BaseTestCase
|
|||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->configDir = IcingaConfig::$configDir;
|
||||
IcingaConfig::$configDir = dirname(__FILE__) . '/ConfigTest/files';
|
||||
$this->oldConfigDir = Config::$configDir;
|
||||
Config::$configDir = dirname(__FILE__) . '/ConfigTest/files';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,77 +25,346 @@ class ConfigTest extends BaseTestCase
|
|||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
IcingaConfig::$configDir = $this->configDir;
|
||||
Config::$configDir = $this->oldConfigDir;
|
||||
}
|
||||
|
||||
public function testAppConfig()
|
||||
public function testWhetherInitializingAConfigWithAssociativeArraysCreatesHierarchicalConfigObjects()
|
||||
{
|
||||
$config = IcingaConfig::app('config', true);
|
||||
$this->assertEquals(1, $config->logging->enable, 'Unexpected value retrieved from config file');
|
||||
// Test non-existent property where null is the default value
|
||||
$this->assertEquals(
|
||||
null,
|
||||
$config->logging->get('disable'),
|
||||
'Unexpected default value for non-existent properties'
|
||||
$config = new Config(array(
|
||||
'a' => 'b',
|
||||
'c' => 'd',
|
||||
'e' => array(
|
||||
'f' => 'g',
|
||||
'h' => 'i',
|
||||
'j' => array(
|
||||
'k' => 'l',
|
||||
'm' => 'n'
|
||||
)
|
||||
)
|
||||
));
|
||||
|
||||
$this->assertInstanceOf(
|
||||
get_class($config),
|
||||
$config->e,
|
||||
'Config::__construct() does not accept two dimensional arrays'
|
||||
);
|
||||
// Test non-existent property using zero as the default value
|
||||
$this->assertEquals(0, $config->logging->get('disable', 0));
|
||||
// Test retrieve full section
|
||||
$this->assertInstanceOf(
|
||||
get_class($config),
|
||||
$config->e->j,
|
||||
'Config::__construct() does not accept multi dimensional arrays'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testWhetherInitializingAConfigWithAssociativeArraysCreatesHierarchicalConfigObjects
|
||||
*/
|
||||
public function testWhetherItIsPossibleToCloneConfigObjects()
|
||||
{
|
||||
$config = new Config(array(
|
||||
'a' => 'b',
|
||||
'c' => array(
|
||||
'd' => 'e'
|
||||
)
|
||||
));
|
||||
$newConfig = clone $config;
|
||||
|
||||
$this->assertNotSame(
|
||||
$config,
|
||||
$newConfig,
|
||||
'Shallow cloning objects of type Config does not seem to work properly'
|
||||
);
|
||||
$this->assertNotSame(
|
||||
$config->c,
|
||||
$newConfig->c,
|
||||
'Deep cloning objects of type Config does not seem to work properly'
|
||||
);
|
||||
}
|
||||
|
||||
public function testWhetherConfigObjectsAreCountable()
|
||||
{
|
||||
$config = new Config(array('a' => 'b', 'c' => array('d' => 'e')));
|
||||
|
||||
$this->assertInstanceOf('Countable', $config, 'Config objects do not implement interface `Countable\'');
|
||||
$this->assertEquals(2, count($config), 'Config objects do not count properties and sections correctly');
|
||||
}
|
||||
|
||||
public function testWhetherConfigObjectsAreTraversable()
|
||||
{
|
||||
$config = new Config(array('a' => 'b', 'c' => 'd'));
|
||||
$config->e = 'f';
|
||||
|
||||
$this->assertInstanceOf('Iterator', $config, 'Config objects do not implement interface `Iterator\'');
|
||||
|
||||
$actual = array();
|
||||
foreach ($config as $key => $value) {
|
||||
$actual[$key] = $value;
|
||||
}
|
||||
|
||||
$this->assertEquals(
|
||||
array('a' => 'b', 'c' => 'd', 'e' => 'f'),
|
||||
$actual,
|
||||
'Config objects do not iterate properly in the order their values were inserted'
|
||||
);
|
||||
}
|
||||
|
||||
public function testWhetherOneCanCheckWhetherConfigObjectsHaveACertainPropertyOrSection()
|
||||
{
|
||||
$config = new Config(array('a' => 'b', 'c' => array('d' => 'e')));
|
||||
|
||||
$this->assertTrue(isset($config->a), 'Config objects do not seem to implement __isset() properly');
|
||||
$this->assertTrue(isset($config->c->d), 'Config objects do not seem to implement __isset() properly');
|
||||
$this->assertFalse(isset($config->d), 'Config objects do not seem to implement __isset() properly');
|
||||
$this->assertFalse(isset($config->c->e), 'Config objects do not seem to implement __isset() properly');
|
||||
$this->assertTrue(isset($config['a']), 'Config object do not seem to implement offsetExists() properly');
|
||||
$this->assertFalse(isset($config['d']), 'Config object do not seem to implement offsetExists() properly');
|
||||
}
|
||||
|
||||
public function testWhetherItIsPossibleToAccessProperties()
|
||||
{
|
||||
$config = new Config(array('a' => 'b', 'c' => null));
|
||||
|
||||
$this->assertEquals('b', $config->a, 'Config objects do not allow property access');
|
||||
$this->assertNull($config['c'], 'Config objects do not allow offset access');
|
||||
$this->assertNull($config->d, 'Config objects do not return NULL as default');
|
||||
}
|
||||
|
||||
public function testWhetherItIsPossibleToSetPropertiesAndSections()
|
||||
{
|
||||
$config = new Config();
|
||||
$config->a = 'b';
|
||||
$config['c'] = array('d' => 'e');
|
||||
|
||||
$this->assertTrue(isset($config->a), 'Config objects do not allow to set properties');
|
||||
$this->assertTrue(isset($config->c), 'Config objects do not allow to set offsets');
|
||||
$this->assertInstanceOf(
|
||||
get_class($config),
|
||||
$config->c,
|
||||
'Config objects do not convert arrays to config objects when set'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException LogicException
|
||||
*/
|
||||
public function testWhetherItIsNotPossibleToAppendProperties()
|
||||
{
|
||||
$config = new Config();
|
||||
$config[] = 'test';
|
||||
}
|
||||
|
||||
public function testWhetherItIsPossibleToUnsetPropertiesAndSections()
|
||||
{
|
||||
$config = new Config(array('a' => 'b', 'c' => array('d' => 'e')));
|
||||
unset($config->a);
|
||||
unset($config['c']);
|
||||
|
||||
$this->assertFalse(isset($config->a), 'Config objects do not allow to unset properties');
|
||||
$this->assertFalse(isset($config->c), 'Config objects do not allow to unset sections');
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testWhetherConfigObjectsAreCountable
|
||||
*/
|
||||
public function testWhetherOneCanCheckIfAConfigObjectHasAnyPropertiesOrSections()
|
||||
{
|
||||
$config = new Config();
|
||||
$this->assertTrue($config->isEmpty(), 'Config objects do not report that they are empty');
|
||||
|
||||
$config->test = 'test';
|
||||
$this->assertFalse($config->isEmpty(), 'Config objects do report that they are empty although they are not');
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testWhetherItIsPossibleToAccessProperties
|
||||
*/
|
||||
public function testWhetherItIsPossibleToRetrieveDefaultValuesForNonExistentPropertiesOrSections()
|
||||
{
|
||||
$config = new Config(array('a' => 'b'));
|
||||
|
||||
$this->assertEquals(
|
||||
'b',
|
||||
$config->get('a'),
|
||||
'Config objects do not return the actual value of existing properties'
|
||||
);
|
||||
$this->assertNull(
|
||||
$config->get('b'),
|
||||
'Config objects do not return NULL as default for non-existent properties'
|
||||
);
|
||||
$this->assertEquals(
|
||||
'test',
|
||||
$config->get('test', 'test'),
|
||||
'Config objects do not allow to define the default value to return for non-existent properties'
|
||||
);
|
||||
}
|
||||
|
||||
public function testWhetherItIsPossibleToRetrieveAllPropertyAndSectionNames()
|
||||
{
|
||||
$config = new Config(array('a' => 'b', 'c' => array('d' => 'e')));
|
||||
|
||||
$this->assertEquals(
|
||||
array('a', 'c'),
|
||||
$config->keys(),
|
||||
'Config objects do not list property and section names correctly'
|
||||
);
|
||||
}
|
||||
|
||||
public function testWhetherConfigObjectsCanBeConvertedToArrays()
|
||||
{
|
||||
$config = new Config(array('a' => 'b', 'c' => array('d' => 'e')));
|
||||
|
||||
$this->assertEquals(
|
||||
array('a' => 'b', 'c' => array('d' => 'e')),
|
||||
$config->toArray(),
|
||||
'Config objects cannot be correctly converted to arrays'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testWhetherConfigObjectsCanBeConvertedToArrays
|
||||
*/
|
||||
public function testWhetherItIsPossibleToMergeConfigObjects()
|
||||
{
|
||||
$config = new Config(array('a' => 'b'));
|
||||
|
||||
$config->merge(array('a' => 'bb', 'c' => 'd', 'e' => array('f' => 'g')));
|
||||
$this->assertEquals(
|
||||
array('a' => 'bb', 'c' => 'd', 'e' => array('f' => 'g')),
|
||||
$config->toArray(),
|
||||
'Config objects cannot be extended with arrays'
|
||||
);
|
||||
|
||||
$config->merge(new Config(array('c' => array('d' => 'ee'), 'e' => array('h' => 'i'))));
|
||||
$this->assertEquals(
|
||||
array('a' => 'bb', 'c' => array('d' => 'ee'), 'e' => array('f' => 'g', 'h' => 'i')),
|
||||
$config->toArray(),
|
||||
'Config objects cannot be extended with other Config objects'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testWhetherItIsPossibleToAccessProperties
|
||||
*/
|
||||
public function testWhetherItIsPossibleToDirectlyRetrieveASectionProperty()
|
||||
{
|
||||
$config = new Config(array('a' => array('b' => 'c')));
|
||||
|
||||
$this->assertEquals(
|
||||
'c',
|
||||
$config->fromSection('a', 'b'),
|
||||
'Config::fromSection does not return the actual value of a section\'s property'
|
||||
);
|
||||
$this->assertNull(
|
||||
$config->fromSection('a', 'c'),
|
||||
'Config::fromSection does not return NULL as default for non-existent section properties'
|
||||
);
|
||||
$this->assertNull(
|
||||
$config->fromSection('b', 'c'),
|
||||
'Config::fromSection does not return NULL as default for non-existent sections'
|
||||
);
|
||||
$this->assertEquals(
|
||||
'test',
|
||||
$config->fromSection('a', 'c', 'test'),
|
||||
'Config::fromSection does not return the given default value for non-existent section properties'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException UnexpectedValueException
|
||||
* @depends testWhetherItIsPossibleToAccessProperties
|
||||
*/
|
||||
public function testWhetherAnExceptionIsThrownWhenTryingToAccessASectionPropertyOnANonSection()
|
||||
{
|
||||
$config = new Config(array('a' => 'b'));
|
||||
$config->fromSection('a', 'b');
|
||||
}
|
||||
|
||||
public function testWhetherConfigResolvePathReturnsValidAbsolutePaths()
|
||||
{
|
||||
$this->assertEquals(
|
||||
Config::$configDir . DIRECTORY_SEPARATOR . 'a' . DIRECTORY_SEPARATOR . 'b.ini',
|
||||
Config::resolvePath(DIRECTORY_SEPARATOR . 'a' . DIRECTORY_SEPARATOR . 'b.ini'),
|
||||
'Config::resolvePath does not produce valid absolute paths'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testWhetherConfigObjectsCanBeConvertedToArrays
|
||||
* @depends testWhetherConfigResolvePathReturnsValidAbsolutePaths
|
||||
*/
|
||||
public function testWhetherItIsPossibleToInitializeAConfigObjectFromAIniFile()
|
||||
{
|
||||
$config = Config::fromIni(Config::resolvePath('config.ini'));
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'disable' => 1,
|
||||
'db' => array(
|
||||
'user' => 'user',
|
||||
'password' => 'password'
|
||||
'logging' => array(
|
||||
'enable' => 1
|
||||
),
|
||||
'backend' => array(
|
||||
'type' => 'db',
|
||||
'user' => 'user',
|
||||
'password' => 'password',
|
||||
'disable' => 1
|
||||
)
|
||||
),
|
||||
$config->backend->toArray()
|
||||
$config->toArray(),
|
||||
'Config::fromIni does not load INI files correctly'
|
||||
);
|
||||
// Test non-existent section using 'default' as default value
|
||||
$this->assertEquals('default', $config->get('magic', 'default'));
|
||||
// Test sub-properties
|
||||
$this->assertEquals('user', $config->backend->db->user);
|
||||
// Test non-existent sub-property using 'UTF-8' as the default value
|
||||
$this->assertEquals('UTF-8', $config->backend->db->get('encoding', 'UTF-8'));
|
||||
// Test invalid property names using false as default value
|
||||
$this->assertEquals(false, $config->backend->get('.', false));
|
||||
$this->assertEquals(false, $config->backend->get('db.', false));
|
||||
$this->assertEquals(false, $config->backend->get('.user', false));
|
||||
// Test retrieve array of sub-properties
|
||||
|
||||
$this->assertInstanceOf(
|
||||
get_class($config),
|
||||
Config::fromIni('nichda'),
|
||||
'Config::fromIni does not return empty configs for non-existent configuration files'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Icinga\Exception\NotReadableError
|
||||
*/
|
||||
public function testWhetherFromIniThrowsAnExceptionOnInsufficientPermission()
|
||||
{
|
||||
Config::fromIni('/etc/shadow');
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testWhetherItIsPossibleToInitializeAConfigObjectFromAIniFile
|
||||
*/
|
||||
public function testWhetherItIsPossibleToRetrieveApplicationConfiguration()
|
||||
{
|
||||
$config = Config::app();
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'user' => 'user',
|
||||
'password' => 'password'
|
||||
'logging' => array(
|
||||
'enable' => 1
|
||||
),
|
||||
'backend' => array(
|
||||
'type' => 'db',
|
||||
'user' => 'user',
|
||||
'password' => 'password',
|
||||
'disable' => 1
|
||||
)
|
||||
),
|
||||
$config->backend->db->toArray()
|
||||
$config->toArray(),
|
||||
'Config::app does not load INI files correctly'
|
||||
);
|
||||
// Test singleton
|
||||
$this->assertEquals($config, IcingaConfig::app('config'));
|
||||
$this->assertEquals(array('logging', 'backend'), $config->keys());
|
||||
$this->assertEquals(array('enable'), $config->keys('logging'));
|
||||
}
|
||||
|
||||
public function testAppExtraConfig()
|
||||
/**
|
||||
* @depends testWhetherItIsPossibleToInitializeAConfigObjectFromAIniFile
|
||||
*/
|
||||
public function testWhetherItIsPossibleToRetrieveModuleConfiguration()
|
||||
{
|
||||
$extraConfig = IcingaConfig::app('extra', true);
|
||||
$this->assertEquals(1, $extraConfig->meta->version);
|
||||
$this->assertEquals($extraConfig, IcingaConfig::app('extra'));
|
||||
}
|
||||
$config = Config::module('amodule');
|
||||
|
||||
public function testModuleConfig()
|
||||
{
|
||||
$moduleConfig = IcingaConfig::module('amodule', 'config', true);
|
||||
$this->assertEquals(1, $moduleConfig->menu->get('breadcrumb'));
|
||||
$this->assertEquals($moduleConfig, IcingaConfig::module('amodule'));
|
||||
}
|
||||
|
||||
public function testModuleExtraConfig()
|
||||
{
|
||||
$moduleExtraConfig = IcingaConfig::module('amodule', 'extra', true);
|
||||
$this->assertEquals(
|
||||
'inetOrgPerson',
|
||||
$moduleExtraConfig->ldap->user->get('ldap_object_class')
|
||||
array(
|
||||
'menu' => array(
|
||||
'breadcrumb' => 1
|
||||
)
|
||||
),
|
||||
$config->toArray(),
|
||||
'Config::module does not load INI files correctly'
|
||||
);
|
||||
$this->assertEquals($moduleExtraConfig, IcingaConfig::module('amodule', 'extra'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
enable = 1
|
||||
|
||||
[backend]
|
||||
db.user = 'user'
|
||||
db.password = 'password'
|
||||
type = "db"
|
||||
user = "user"
|
||||
password = "password"
|
||||
disable = 1
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
[meta]
|
||||
version = 1
|
|
@ -1,2 +0,0 @@
|
|||
[ldap]
|
||||
user.ldap_object_class = inetOrgPerson
|
|
@ -4,10 +4,9 @@
|
|||
|
||||
namespace Tests\Icinga\Config;
|
||||
|
||||
use Zend_Config;
|
||||
use Zend_Config_Ini;
|
||||
use Icinga\File\Ini\IniWriter;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
use Icinga\Application\Config;
|
||||
|
||||
class IniWriterTest extends BaseTestCase
|
||||
{
|
||||
|
@ -32,23 +31,25 @@ class IniWriterTest extends BaseTestCase
|
|||
|
||||
public function testWhetherSimplePropertiesAreInsertedInEmptyFiles()
|
||||
{
|
||||
$this->markTestSkipped('Implementation has changed. Section-less properties are not supported anymore');
|
||||
$target = $this->writeConfigToTemporaryFile('');
|
||||
$config = new Zend_Config(array('key' => 'value'));
|
||||
$config = new Config(array('key' => 'value'));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = new Zend_Config_Ini($target);
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertEquals('value', $newConfig->get('key'), 'IniWriter does not insert in empty files');
|
||||
}
|
||||
|
||||
public function testWhetherSimplePropertiesAreInsertedInExistingFiles()
|
||||
{
|
||||
$this->markTestSkipped('Implementation has changed. Section-less properties are not supported anymore');
|
||||
$target = $this->writeConfigToTemporaryFile('key1 = "1"');
|
||||
$config = new Zend_Config(array('key2' => '2'));
|
||||
$config = new Config(array('key2' => '2'));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = new Zend_Config_Ini($target);
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertEquals('2', $newConfig->get('key2'), 'IniWriter does not insert in existing files');
|
||||
}
|
||||
|
||||
|
@ -57,12 +58,13 @@ class IniWriterTest extends BaseTestCase
|
|||
*/
|
||||
public function testWhetherSimplePropertiesAreUpdated()
|
||||
{
|
||||
$this->markTestSkipped('Implementation has changed. Section-less properties are not supported anymore');
|
||||
$target = $this->writeConfigToTemporaryFile('key = "value"');
|
||||
$config = new Zend_Config(array('key' => 'eulav'));
|
||||
$config = new Config(array('key' => 'eulav'));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = new Zend_Config_Ini($target);
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertEquals('eulav', $newConfig->get('key'), 'IniWriter does not update simple properties');
|
||||
}
|
||||
|
||||
|
@ -71,25 +73,26 @@ class IniWriterTest extends BaseTestCase
|
|||
*/
|
||||
public function testWhetherSimplePropertiesAreDeleted()
|
||||
{
|
||||
$this->markTestSkipped('Implementation has changed. Section-less properties are not supported anymore');
|
||||
$target = $this->writeConfigToTemporaryFile('key = "value"');
|
||||
$config = new Zend_Config(array());
|
||||
$config = new Config(array());
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = new Zend_Config_Ini($target);
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertNull($newConfig->get('key'), 'IniWriter does not delete simple properties');
|
||||
}
|
||||
|
||||
public function testWhetherNestedPropertiesAreInserted()
|
||||
{
|
||||
$target = $this->writeConfigToTemporaryFile('');
|
||||
$config = new Zend_Config(array('a' => array('b' => 'c')));
|
||||
$config = new Config(array('a' => array('b' => 'c')));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = new Zend_Config_Ini($target);
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertInstanceOf(
|
||||
'\Zend_Config',
|
||||
get_class($newConfig),
|
||||
$newConfig->get('a'),
|
||||
'IniWriter does not insert nested properties'
|
||||
);
|
||||
|
@ -105,14 +108,15 @@ class IniWriterTest extends BaseTestCase
|
|||
*/
|
||||
public function testWhetherNestedPropertiesAreUpdated()
|
||||
{
|
||||
$this->markTestSkipped('Implementation has changed. Section-less properties are not supported anymore');
|
||||
$target = $this->writeConfigToTemporaryFile('a.b = "c"');
|
||||
$config = new Zend_Config(array('a' => array('b' => 'cc')));
|
||||
$config = new Config(array('a' => array('b' => 'cc')));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = new Zend_Config_Ini($target);
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertInstanceOf(
|
||||
'\Zend_Config',
|
||||
get_class($newConfig),
|
||||
$newConfig->get('a'),
|
||||
'IniWriter does not update nested properties'
|
||||
);
|
||||
|
@ -128,12 +132,13 @@ class IniWriterTest extends BaseTestCase
|
|||
*/
|
||||
public function testWhetherNestedPropertiesAreDeleted()
|
||||
{
|
||||
$this->markTestSkipped('Implementation has changed. Section-less properties are not supported anymore');
|
||||
$target = $this->writeConfigToTemporaryFile('a.b = "c"');
|
||||
$config = new Zend_Config(array());
|
||||
$config = new Config(array());
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = new Zend_Config_Ini($target);
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertNull(
|
||||
$newConfig->get('a'),
|
||||
'IniWriter does not delete nested properties'
|
||||
|
@ -143,13 +148,13 @@ class IniWriterTest extends BaseTestCase
|
|||
public function testWhetherSimpleSectionPropertiesAreInserted()
|
||||
{
|
||||
$target = $this->writeConfigToTemporaryFile('');
|
||||
$config = new Zend_Config(array('section' => array('key' => 'value')));
|
||||
$config = new Config(array('section' => array('key' => 'value')));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = new Zend_Config_Ini($target);
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertInstanceOf(
|
||||
'\Zend_Config',
|
||||
get_class($newConfig),
|
||||
$newConfig->get('section'),
|
||||
'IniWriter does not insert sections'
|
||||
);
|
||||
|
@ -170,11 +175,11 @@ class IniWriterTest extends BaseTestCase
|
|||
key = "value"
|
||||
EOD
|
||||
);
|
||||
$config = new Zend_Config(array('section' => array('key' => 'eulav')));
|
||||
$config = new Config(array('section' => array('key' => 'eulav')));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = new Zend_Config_Ini($target);
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertEquals(
|
||||
'eulav',
|
||||
$newConfig->get('section')->get('key'),
|
||||
|
@ -192,11 +197,11 @@ EOD
|
|||
key = "value"
|
||||
EOD
|
||||
);
|
||||
$config = new Zend_Config(array('section' => array()));
|
||||
$config = new Config(array('section' => array()));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = new Zend_Config_Ini($target);
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertNull(
|
||||
$newConfig->get('section')->get('key'),
|
||||
'IniWriter does not delete simple section properties'
|
||||
|
@ -205,19 +210,20 @@ EOD
|
|||
|
||||
public function testWhetherNestedSectionPropertiesAreInserted()
|
||||
{
|
||||
$this->markTestSkipped('Implementation has changed. Config::fromIni cannot handle nested properties anymore');
|
||||
$target = $this->writeConfigToTemporaryFile('');
|
||||
$config = new Zend_Config(array('section' => array('a' => array('b' => 'c'))));
|
||||
$config = new Config(array('section' => array('a' => array('b' => 'c'))));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = new Zend_Config_Ini($target);
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertInstanceOf(
|
||||
'\Zend_Config',
|
||||
get_class($newConfig),
|
||||
$newConfig->get('section'),
|
||||
'IniWriter does not insert sections'
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
'\Zend_Config',
|
||||
get_class($newConfig),
|
||||
$newConfig->get('section')->get('a'),
|
||||
'IniWriter does not insert nested section properties'
|
||||
);
|
||||
|
@ -238,11 +244,11 @@ EOD
|
|||
a.b = "c"
|
||||
EOD
|
||||
);
|
||||
$config = new Zend_Config(array('section' => array('a' => array('b' => 'cc'))));
|
||||
$config = new Config(array('section' => array('a' => array('b' => 'cc'))));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = new Zend_Config_Ini($target);
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertEquals(
|
||||
'cc',
|
||||
$newConfig->get('section')->get('a')->get('b'),
|
||||
|
@ -260,11 +266,11 @@ EOD
|
|||
a.b = "c"
|
||||
EOD
|
||||
);
|
||||
$config = new Zend_Config(array('section' => array()));
|
||||
$config = new Config(array('section' => array()));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = new Zend_Config_Ini($target);
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertNull(
|
||||
$newConfig->get('section')->get('a'),
|
||||
'IniWriter does not delete nested section properties'
|
||||
|
@ -273,8 +279,11 @@ EOD
|
|||
|
||||
public function testWhetherSimplePropertiesOfExtendingSectionsAreInserted()
|
||||
{
|
||||
$this->markTestSkipped(
|
||||
'Implementation has changed. There is no "Extend" functionality anymore in our Config object'
|
||||
);
|
||||
$target = $this->writeConfigToTemporaryFile('');
|
||||
$config = new Zend_Config(
|
||||
$config = new Config(
|
||||
array(
|
||||
'foo' => array('key1' => '1'),
|
||||
'bar' => array('key2' => '2')
|
||||
|
@ -284,14 +293,14 @@ EOD
|
|||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = new Zend_Config_Ini($target);
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertInstanceOf(
|
||||
'\Zend_Config',
|
||||
get_class($newConfig),
|
||||
$newConfig->get('foo'),
|
||||
'IniWriter does not insert extended sections'
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
'\Zend_Config',
|
||||
get_class($newConfig),
|
||||
$newConfig->get('bar'),
|
||||
'IniWriter does not insert extending sections'
|
||||
);
|
||||
|
@ -312,6 +321,9 @@ EOD
|
|||
*/
|
||||
public function testWhetherSimplePropertiesOfExtendingSectionsAreUpdated()
|
||||
{
|
||||
$this->markTestSkipped(
|
||||
'Implementation has changed. There is no "Extend" functionality anymore in our Config object'
|
||||
);
|
||||
$target = $this->writeConfigToTemporaryFile(<<<'EOD'
|
||||
[foo]
|
||||
key1 = "1"
|
||||
|
@ -320,7 +332,7 @@ key1 = "1"
|
|||
key2 = "2"
|
||||
EOD
|
||||
);
|
||||
$config = new Zend_Config(
|
||||
$config = new Config(
|
||||
array(
|
||||
'foo' => array('key1' => '1'),
|
||||
'bar' => array('key2' => '22')
|
||||
|
@ -330,7 +342,7 @@ EOD
|
|||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = new Zend_Config_Ini($target);
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertEquals(
|
||||
'22',
|
||||
$newConfig->get('bar')->get('key2'),
|
||||
|
@ -343,6 +355,9 @@ EOD
|
|||
*/
|
||||
public function testWhetherSimplePropertiesOfExtendingSectionsAreDeleted()
|
||||
{
|
||||
$this->markTestSkipped(
|
||||
'Implementation has changed. There is no "Extend" functionality anymore in our Config object'
|
||||
);
|
||||
$target = $this->writeConfigToTemporaryFile(<<<'EOD'
|
||||
[foo]
|
||||
key1 = "1"
|
||||
|
@ -351,7 +366,7 @@ key1 = "1"
|
|||
key2 = "2"
|
||||
EOD
|
||||
);
|
||||
$config = new Zend_Config(
|
||||
$config = new Config(
|
||||
array(
|
||||
'foo' => array('key1' => '1'),
|
||||
'bar' => array()
|
||||
|
@ -361,7 +376,7 @@ EOD
|
|||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = new Zend_Config_Ini($target);
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertNull(
|
||||
$newConfig->get('bar')->get('key2'),
|
||||
'IniWriter does not delete simple properties of extending sections'
|
||||
|
@ -370,8 +385,11 @@ EOD
|
|||
|
||||
public function testWhetherNestedPropertiesOfExtendingSectionsAreInserted()
|
||||
{
|
||||
$this->markTestSkipped(
|
||||
'Implementation has changed. There is no "Extend" functionality anymore in our Config object'
|
||||
);
|
||||
$target = $this->writeConfigToTemporaryFile('');
|
||||
$config = new Zend_Config(
|
||||
$config = new Config(
|
||||
array(
|
||||
'foo' => array('a' => array('b' => 'c')),
|
||||
'bar' => array('d' => array('e' => 'f'))
|
||||
|
@ -381,19 +399,19 @@ EOD
|
|||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = new Zend_Config_Ini($target);
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertInstanceOf(
|
||||
'\Zend_Config',
|
||||
get_class($newConfig),
|
||||
$newConfig->get('foo'),
|
||||
'IniWriter does not insert extended sections'
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
'\Zend_Config',
|
||||
get_class($newConfig),
|
||||
$newConfig->get('bar'),
|
||||
'IniWriter does not insert extending sections'
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
'\Zend_Config',
|
||||
get_class($newConfig),
|
||||
$newConfig->get('bar')->get('d'),
|
||||
'IniWriter does not insert nested properties into extending sections'
|
||||
);
|
||||
|
@ -422,7 +440,7 @@ a.b = "c"
|
|||
d.e = "f"
|
||||
EOD
|
||||
);
|
||||
$config = new Zend_Config(
|
||||
$config = new Config(
|
||||
array(
|
||||
'foo' => array('a' => array('b' => 'c')),
|
||||
'bar' => array('d' => array('e' => 'ff'))
|
||||
|
@ -432,7 +450,7 @@ EOD
|
|||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = new Zend_Config_Ini($target);
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertEquals(
|
||||
'ff',
|
||||
$newConfig->get('bar')->get('d')->get('e'),
|
||||
|
@ -445,6 +463,9 @@ EOD
|
|||
*/
|
||||
public function testWhetherNestedPropertiesOfExtendingSectionsAreDeleted()
|
||||
{
|
||||
$this->markTestSkipped(
|
||||
'Implementation has changed. There is no "Extend" functionality anymore in our Config object'
|
||||
);
|
||||
$target = $this->writeConfigToTemporaryFile(<<<'EOD'
|
||||
[foo]
|
||||
a.b = "c"
|
||||
|
@ -453,7 +474,7 @@ a.b = "c"
|
|||
d.e = "f"
|
||||
EOD
|
||||
);
|
||||
$config = new Zend_Config(
|
||||
$config = new Config(
|
||||
array(
|
||||
'foo' => array('a' => array('b' => 'c')),
|
||||
'bar' => array()
|
||||
|
@ -463,7 +484,7 @@ EOD
|
|||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer->write();
|
||||
|
||||
$newConfig = new Zend_Config_Ini($target);
|
||||
$newConfig = Config::fromIni($target);
|
||||
$this->assertNull(
|
||||
$newConfig->get('bar')->get('d'),
|
||||
'IniWriter does not delete nested properties of extending sections'
|
||||
|
@ -506,7 +527,7 @@ EOD;
|
|||
$target = $this->writeConfigToTemporaryFile($config);
|
||||
$writer = new IniWriter(
|
||||
array(
|
||||
'config' => new Zend_Config(
|
||||
'config' => new Config(
|
||||
array(
|
||||
'three' => array(
|
||||
'foo' => array(
|
||||
|
@ -561,7 +582,7 @@ EOD;
|
|||
$target = $this->writeConfigToTemporaryFile($config);
|
||||
$writer = new IniWriter(
|
||||
array(
|
||||
'config' => new Zend_Config(
|
||||
'config' => new Config(
|
||||
array(
|
||||
'two' => array(),
|
||||
'one' => array()
|
||||
|
@ -589,7 +610,7 @@ key = "value"
|
|||
EOD;
|
||||
$target = $this->writeConfigToTemporaryFile($config);
|
||||
$writer = new IniWriter(
|
||||
array('config' => new Zend_Config(array('key' => 'value')), 'filename' => $target)
|
||||
array('config' => new Config(array('key' => 'value')), 'filename' => $target)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
|
@ -610,7 +631,7 @@ EOD;
|
|||
$target = $this->writeConfigToTemporaryFile($config);
|
||||
$writer = new IniWriter(
|
||||
array(
|
||||
'config' => new Zend_Config(
|
||||
'config' => new Config(
|
||||
array(
|
||||
'foo' => 1337,
|
||||
'bar' => 7331,
|
||||
|
@ -638,7 +659,7 @@ key = "value"
|
|||
EOD;
|
||||
$target = $this->writeConfigToTemporaryFile($config);
|
||||
$writer = new IniWriter(
|
||||
array('config' => new Zend_Config(array('section' => array('key' => 'value'))), 'filename' => $target)
|
||||
array('config' => new Config(array('section' => array('key' => 'value'))), 'filename' => $target)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
|
@ -660,7 +681,7 @@ EOD;
|
|||
$target = $this->writeConfigToTemporaryFile($config);
|
||||
$writer = new IniWriter(
|
||||
array(
|
||||
'config' => new Zend_Config(
|
||||
'config' => new Config(
|
||||
array(
|
||||
'section' => array(
|
||||
'foo' => 1337,
|
||||
|
@ -685,7 +706,7 @@ EOD;
|
|||
{
|
||||
$normalKeys = new IniWriter(
|
||||
array (
|
||||
'config' => new Zend_Config(array (
|
||||
'config' => new Config(array (
|
||||
'foo' => 'bar',
|
||||
'nest' => array (
|
||||
'nested' => array (
|
||||
|
@ -706,7 +727,7 @@ EOD;
|
|||
|
||||
$nestedKeys = new IniWriter(
|
||||
array (
|
||||
'config' => new Zend_Config(array (
|
||||
'config' => new Config(array (
|
||||
'foo' => 'bar',
|
||||
'nest.nested.stuff' => 'nested configuration element',
|
||||
'preserving.ini.writer' => 'n',
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Tests\Icinga\Logger\Writer;
|
||||
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Application\Logger\Writer\FileWriter;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
|
@ -27,7 +27,7 @@ class StreamWriterTest extends BaseTestCase
|
|||
|
||||
public function testWhetherStreamWriterCreatesMissingFiles()
|
||||
{
|
||||
new FileWriter(new Zend_Config(array('file' => $this->target)));
|
||||
new FileWriter(new Config(array('file' => $this->target)));
|
||||
$this->assertFileExists($this->target, 'StreamWriter does not create missing files on initialization');
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ class StreamWriterTest extends BaseTestCase
|
|||
*/
|
||||
public function testWhetherStreamWriterWritesMessages()
|
||||
{
|
||||
$writer = new FileWriter(new Zend_Config(array('file' => $this->target)));
|
||||
$writer = new FileWriter(new Config(array('file' => $this->target)));
|
||||
$writer->log(Logger::ERROR, 'This is a test error');
|
||||
$log = file_get_contents($this->target);
|
||||
$this->assertContains('This is a test error', $log, 'StreamWriter does not write log messages');
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
|
||||
namespace Tests\Icinga\Protocol\Ldap;
|
||||
|
||||
use Zend_Config;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Protocol\Ldap\Connection;
|
||||
|
||||
class QueryTest extends BaseTestCase
|
||||
{
|
||||
private function emptySelect()
|
||||
{
|
||||
$config = new Zend_Config(
|
||||
$config = new Config(
|
||||
array(
|
||||
'hostname' => 'localhost',
|
||||
'root_dn' => 'dc=example,dc=com',
|
||||
|
|
|
@ -6,8 +6,8 @@ namespace Tests\Icinga\User\Preferences\Store;
|
|||
|
||||
use Mockery;
|
||||
use Exception;
|
||||
use Zend_Config;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\User\Preferences\Store\DbStore;
|
||||
|
||||
class DatabaseMock
|
||||
|
@ -165,7 +165,7 @@ class DbStoreTest extends BaseTestCase
|
|||
protected function getStore($dbMock)
|
||||
{
|
||||
return new DbStoreWithSetPreferences(
|
||||
new Zend_Config(
|
||||
new Config(
|
||||
array(
|
||||
'connection' => Mockery::mock(array('getDbAdapter' => $dbMock))
|
||||
)
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
namespace Tests\Icinga\User\Preferences\Store;
|
||||
|
||||
use Mockery;
|
||||
use Zend_Config;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\User\Preferences\Store\IniStore;
|
||||
|
||||
class IniStoreWithSetGetPreferencesAndEmptyWrite extends IniStore
|
||||
|
@ -56,7 +56,7 @@ class IniStoreTest extends BaseTestCase
|
|||
protected function getStore()
|
||||
{
|
||||
return new IniStoreWithSetGetPreferencesAndEmptyWrite(
|
||||
new Zend_Config(
|
||||
new Config(
|
||||
array(
|
||||
'location' => 'some/Path/To/Some/Directory'
|
||||
)
|
||||
|
|
|
@ -4,21 +4,21 @@
|
|||
|
||||
namespace Tests\Icinga\Web;
|
||||
|
||||
use Zend_Config;
|
||||
use Icinga\Web\Menu;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
use Icinga\Application\Config;
|
||||
|
||||
class MenuTest extends BaseTestCase
|
||||
{
|
||||
public function testWhetherMenusAreNaturallySorted()
|
||||
{
|
||||
$menu = new Menu('test');
|
||||
$menu->addSubMenu(5, new Zend_Config(array('title' => 'ccc5')));
|
||||
$menu->addSubMenu(0, new Zend_Config(array('title' => 'aaa')));
|
||||
$menu->addSubMenu(3, new Zend_Config(array('title' => 'ccc')));
|
||||
$menu->addSubMenu(2, new Zend_Config(array('title' => 'bbb')));
|
||||
$menu->addSubMenu(4, new Zend_Config(array('title' => 'ccc2')));
|
||||
$menu->addSubMenu(1, new Zend_Config(array('title' => 'bb')));
|
||||
$menu->addSubMenu(5, new Config(array('title' => 'ccc5')));
|
||||
$menu->addSubMenu(0, new Config(array('title' => 'aaa')));
|
||||
$menu->addSubMenu(3, new Config(array('title' => 'ccc')));
|
||||
$menu->addSubMenu(2, new Config(array('title' => 'bbb')));
|
||||
$menu->addSubMenu(4, new Config(array('title' => 'ccc2')));
|
||||
$menu->addSubMenu(1, new Config(array('title' => 'bb')));
|
||||
|
||||
$this->assertEquals(
|
||||
array('aaa', 'bb', 'bbb', 'ccc', 'ccc2', 'ccc5'),
|
||||
|
|
Loading…
Reference in New Issue