Configure fixes, regression test for 4606

The configure routine still has to be improved, right now unused
authentication backends are commented out

refs #4491
refs #4606
refs #4640
This commit is contained in:
Jannis Moßhammer 2013-08-27 14:37:22 +02:00
parent 4e41ce5cdc
commit d0ac97f335
24 changed files with 330 additions and 191 deletions

View File

@ -101,7 +101,9 @@ class ConfigController extends BaseConfigController
if (!$this->writeConfigFile($form->getConfig(), 'config')) { if (!$this->writeConfigFile($form->getConfig(), 'config')) {
return; return;
} }
$this->redirectNow('/config'); $this->view->successMessage = "Config Sucessfully Updated";
$form->setConfiguration(IcingaConfig::app(), true);
} }
$this->view->form = $form; $this->view->form = $form;
} }
@ -116,11 +118,11 @@ class ConfigController extends BaseConfigController
$form->setConfiguration(IcingaConfig::app()); $form->setConfiguration(IcingaConfig::app());
$form->setRequest($this->_request); $form->setRequest($this->_request);
if ($form->isSubmittedAndValid()) { if ($form->isSubmittedAndValid()) {
$config = $form->getConfig();
if (!$this->writeConfigFile($form->getConfig(), 'config')) { if (!$this->writeConfigFile($form->getConfig(), 'config')) {
return; return;
} }
$this->redirectNow('/config/logging'); $this->view->successMessage = "Config Sucessfully Updated";
$form->setConfiguration(IcingaConfig::app(), true);
} }
$this->view->form = $form; $this->view->form = $form;
} }
@ -141,10 +143,12 @@ class ConfigController extends BaseConfigController
*/ */
public function moduleenableAction() public function moduleenableAction()
{ {
$module = $this->_getParam('name');
$manager = Icinga::app()->getModuleManager(); $manager = Icinga::app()->getModuleManager();
$manager->enableModule($this->_getParam('name')); $manager->enableModule($module);
$manager->loadModule($this->_getParam('name')); $manager->loadModule($module);
$this->redirectNow('config/moduleoverview?_render=body'); $this->view->successMessage = 'Module "' . $module . '" enabled';
$this->moduleoverviewAction();
} }
/** /**
@ -152,9 +156,11 @@ class ConfigController extends BaseConfigController
*/ */
public function moduledisableAction() public function moduledisableAction()
{ {
$module = $this->_getParam('name');
$manager = Icinga::app()->getModuleManager(); $manager = Icinga::app()->getModuleManager();
$manager->disableModule($this->_getParam('name')); $manager->disableModule($module);
$this->redirectNow('config/moduleoverview?_render=body'); $this->view->successMessage = 'Module "' . $module . '" disabled';
$this->moduleoverviewAction();
} }
/** /**

View File

@ -131,10 +131,10 @@ abstract class BaseBackendForm extends Form
} }
/** /**
* Add a forcebox at the beginning of the form which allows to skip logic connection validation * Add checkbox at the beginning of the form which allows to skip logic connection validation
*
*/ */
private function addForceCreationCheckbox() { private function addForceCreationCheckbox()
{
$checkbox = new \Zend_Form_Element_Checkbox( $checkbox = new \Zend_Form_Element_Checkbox(
array( array(
'name' => 'backend_force_creation', 'name' => 'backend_force_creation',
@ -148,7 +148,7 @@ abstract class BaseBackendForm extends Form
} }
/** /**
* Validate this form with the Zend validation mechanismn and perform a logic validation of the connection. * Validate this form with the Zend validation mechanism and perform a logic validation of the connection.
* *
* If logic validation fails, the 'backend_force_creation' checkbox is prepended to the form to allow users to * If logic validation fails, the 'backend_force_creation' checkbox is prepended to the form to allow users to
* skip the logic connection validation. * skip the logic connection validation.
@ -165,7 +165,7 @@ abstract class BaseBackendForm extends Form
if ($this->getRequest()->getPost('backend_force_creation')) { if ($this->getRequest()->getPost('backend_force_creation')) {
return true; return true;
} }
if(!$this->validateAuthenticationBackend()) { if (!$this->isValidAuthenticationBackend()) {
$this->addForceCreationCheckbox(); $this->addForceCreationCheckbox();
return false; return false;
} }
@ -188,5 +188,5 @@ abstract class BaseBackendForm extends Form
* *
* @return bool True when validation succeeded, otherwise false * @return bool True when validation succeeded, otherwise false
*/ */
abstract public function validateAuthenticationBackend(); abstract public function isValidAuthenticationBackend();
} }

View File

@ -120,7 +120,13 @@ class DbBackendForm extends BaseBackendForm
); );
} }
public function validateAuthenticationBackend() /**
* Validate the current configuration by creating a backend and requesting the user count
*
* @return bool True when the backend is valid, false otherwise
* @see BaseBackendForm::isValidAuthenticationBackend
*/
public function isValidAuthenticationBackend()
{ {
try { try {
$name = $this->getBackendName(); $name = $this->getBackendName();

View File

@ -164,14 +164,19 @@ class LdapBackendForm extends BaseBackendForm
); );
} }
/**
* Validate the current configuration by creating a backend and requesting the user count
public function validateAuthenticationBackend() *
* @return bool True when the backend is valid, false otherwise
* @see BaseBackendForm::isValidAuthenticationBacken
*/
public function isValidAuthenticationBackend()
{ {
try { try {
$cfg = $this->getConfig(); $cfg = $this->getConfig();
$backendName = 'backend_' . $this->filterName($this->getBackendName()) . '_name';
$testConn = new LdapUserBackend( $testConn = new LdapUserBackend(
new Zend_Config($cfg[$this->getValue('backend_' . $this->filterName($this->getBackendName()) . '_name')]) new Zend_Config($cfg[$this->getValue($backendName)])
); );
if ($testConn->getUserCount() === 0) { if ($testConn->getUserCount() === 0) {

View File

@ -322,7 +322,7 @@ class GeneralForm extends Form
if ($preferences === null) { if ($preferences === null) {
$preferences = new Zend_Config(array()); $preferences = new Zend_Config(array());
} }
$this->setName('form_config_general');
$this->addDevelopmentCheckbox($global); $this->addDevelopmentCheckbox($global);
$this->addTimezoneSelection($global); $this->addTimezoneSelection($global);
$this->addModuleSettings($global); $this->addModuleSettings($global);

View File

@ -122,6 +122,7 @@ class LoggingForm extends Form
*/ */
public function create() public function create()
{ {
$this->setName('form_config_logging');
if ($this->config === null) { if ($this->config === null) {
$this->config = new Zend_Config(array()); $this->config = new Zend_Config(array());
} }

View File

@ -1,2 +1,10 @@
<?= $this->tabs->render($this); ?> <?= $this->tabs->render($this); ?>
<?php if ($this->successMessage): ?>
<div class="alert alert-success">
<i>{{OK_ICON}}</i>
<strong><?= $this->escape($this->successMessage); ?></strong>
</div>
<?php endif; ?>
<?= $this->form ?> <?= $this->form ?>

View File

@ -2,6 +2,13 @@
<?php $errors = $this->form->getErrorMessages(); ?> <?php $errors = $this->form->getErrorMessages(); ?>
<?php if ($this->successMessage): ?>
<div class="alert alert-success">
<i>{{OK_ICON}}</i>
<strong><?= $this->escape($this->successMessage); ?></strong>
</div>
<?php endif; ?>
<?php if (!empty($errors)) : ?> <?php if (!empty($errors)) : ?>
<div class="alert alert-danger"> <div class="alert alert-danger">
<h4>Errors occured when trying to save the project.</h4> <h4>Errors occured when trying to save the project.</h4>

View File

@ -8,6 +8,14 @@ $modules = $this->modules->paginate();
<?= $this->tabs->render($this); ?> <?= $this->tabs->render($this); ?>
<h3>Installed Modules</h3> <h3>Installed Modules</h3>
<?php if ($this->successMessage): ?>
<div class="alert alert-success">
<i>{{OK_ICON}}</i>
<strong><?= $this->escape($this->successMessage); ?></strong>
</div>
<?php endif; ?>
<?= $this->paginationControl($modules, null, null, array( <?= $this->paginationControl($modules, null, null, array(
'preserve' => $this->preserve 'preserve' => $this->preserve
)); ));

View File

@ -1,24 +1,33 @@
[ldap-authentication] ; authentication.ini
backend=ldap ;
hostname=@ldap_host@ ; Each section listed in this configuration represents a single backend
port=@ldap_port@ ; that can be used to authenticate users or groups. Each databse backend must refer
root_dn='@ldap_rootdn@' ; to a resource defined in resources.ini,
bind_dn='@ldap_binddn@' ;
bind_pw=@ldap_bindpass@ ; The order of entries in this configuration is used to determine the fallback
; priority in case of an error. If the resource referenced in the first
; entry is not reachable, the next lower entry will be used for authentication.
; Please be aware that this behaviour is not valid for the authentication itself.
; The authentication will only be done against the one available resource with the highest
; priority.
@use_ldap_auth@[ldap_authentication]
@use_ldap_auth@backend = "ldap"
@use_ldap_auth@target = "user"
@use_ldap_auth@hostname = "@ldap_host@"
@use_ldap_auth@port = "@ldap_port@"
@use_ldap_auth@root_dn = "@ldap_rootdn@"
@use_ldap_auth@bind_dn = "@ldap_binddn@"
@use_ldap_auth@bind_pw = "@ldap_bindpass@"
; Attributes for ldap user lookup ; Attributes for ldap user lookup
user.ldap_object_class=@ldap_user_objectclass@ @use_ldap_auth@user_class = "@ldap_user_objectclass@"
user.ldap_name_attribute=@ldap_attribute_username@ @use_ldap_auth@user_name_attribute = "@ldap_attribute_username@"
user.password_attribute=@ldap_attribute_password@ @use_ldap_auth@user_password_attribute = "@ldap_attribute_password@"
group.ldap_object_class=@ldap_group_objectclass@
group.ldap_name_attribute=@ldap_attribute_groupname@
[internal-authentication]
backend=db
type=@internal_db_type@
host=@internal_db_host@
port=@internal_db_port@
database=@internal_db_name@
user=@internal_db_user@
password=@internal_db_pass@
@use_internal_auth@[internal_authentication]
@use_internal_auth@backend = db
@use_internal_auth@target = "user"
@use_internal_auth@resource = "authentication_db"

View File

@ -13,21 +13,13 @@
; be interpreted. Currently only the resource type *db* is available. ; be interpreted. Currently only the resource type *db* is available.
[icingaweb-pgsql] [internal_db]
type = db type = db
db = pgsql ; PostgreSQL db = @internal_db_type@
host = localhost host = @internal_db_host@
password = icinga password = @internal_db_password@
username = icingaweb username = @internal_db_user@
dbname = icingaweb dbname = @internal_db_database@
[icingaweb-mysql]
type = db
db = mysql ; MySQL
host = localhost
password = icinga
username = icingaweb
dbname = icingaweb
[ido] [ido]
type = db type = db

82
configure vendored
View File

@ -590,10 +590,8 @@ ac_subst_vars='LTLIBOBJS
LIBOBJS LIBOBJS
INSTALL_OPTS_WEB INSTALL_OPTS_WEB
INSTALL_OPTS INSTALL_OPTS
ldap_enabled use_internal_auth
ido_enabled use_ldap_auth
statusdat_enabled
livestatus_enabled
icinga_commandpipe icinga_commandpipe
livestatus_socket livestatus_socket
objects_cache_file objects_cache_file
@ -2400,7 +2398,7 @@ fi
if test "${with_internal_authentication+set}" = set; then : if test "${with_internal_authentication+set}" = set; then :
withval=$with_internal_authentication; internal_authentication=yes withval=$with_internal_authentication; internal_authentication=yes
else else
internal_authentication=def internal_authentication=yes
fi fi
@ -2818,7 +2816,6 @@ fi
ido_enabled="disable=1" ido_enabled="disable=1"
statusdat_enabled="disable=1" statusdat_enabled="disable=1"
livestatus_enabled="disable=1" livestatus_enabled="disable=1"
ldap_enabled="disable=1"
case $icinga_backend in #( case $icinga_backend in #(
"ido") : "ido") :
@ -2831,6 +2828,7 @@ case $icinga_backend in #(
statusdat_enabled="" ;; statusdat_enabled="" ;;
esac esac
use_ldap_auth=";"
if test "x$ldap_authentication" != xno; then : if test "x$ldap_authentication" != xno; then :
for x in ldap;do for x in ldap;do
@ -2844,7 +2842,25 @@ else
fi fi
done done
ldap_enabled="" use_ldap_auth=""
fi
use_internal_auth=";"
if test "x$internal_authentication" != xno; then :
for x in ldap;do
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if php has $x module" >&5
$as_echo_n "checking if php has $x module... " >&6; }
if php -m | $GREP -iq "^$x$" ; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
$as_echo "found" >&6; }
else
as_fn_error $? "not found" "$LINENO" 5
fi
done
use_internal_auth=""
fi fi
@ -2909,55 +2925,6 @@ fi
# Internal db setup
# ldap setup
# backend setup
# ido backend variables
# status.dat backend
# livestatus backend
# command pipe
# Comment placeholders for toggling backends
# Application and installation # Application and installation
@ -2966,7 +2933,7 @@ fi
# #
# Create config files # Create config files
# #
ac_config_files="$ac_config_files Makefile config/authentication.ini config/resources.ini config/modules/monitoring/backends.ini etc/apache/icingaweb.conf" ac_config_files="$ac_config_files Makefile config/authentication.ini config/resources.ini config/modules/monitoring/backends.ini etc/apache/icingaweb.conf public/.htaccess"
# #
@ -3683,6 +3650,7 @@ do
"config/resources.ini") CONFIG_FILES="$CONFIG_FILES config/resources.ini" ;; "config/resources.ini") CONFIG_FILES="$CONFIG_FILES config/resources.ini" ;;
"config/modules/monitoring/backends.ini") CONFIG_FILES="$CONFIG_FILES config/modules/monitoring/backends.ini" ;; "config/modules/monitoring/backends.ini") CONFIG_FILES="$CONFIG_FILES config/modules/monitoring/backends.ini" ;;
"etc/apache/icingaweb.conf") CONFIG_FILES="$CONFIG_FILES etc/apache/icingaweb.conf" ;; "etc/apache/icingaweb.conf") CONFIG_FILES="$CONFIG_FILES etc/apache/icingaweb.conf" ;;
"public/.htaccess") CONFIG_FILES="$CONFIG_FILES public/.htaccess" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac esac

View File

@ -126,7 +126,7 @@ AC_ARG_WITH([internal_db_user],
AC_ARG_WITH([internal_authentication], AC_ARG_WITH([internal_authentication],
AC_HELP_STRING([--with-internal-authentication], [use the internal database for authentication (default: yes)]), AC_HELP_STRING([--with-internal-authentication], [use the internal database for authentication (default: yes)]),
internal_authentication=yes, internal_authentication=yes,
internal_authentication=def internal_authentication=yes
) )
AC_ARG_WITH([ldap_authentication], AC_ARG_WITH([ldap_authentication],
@ -346,7 +346,6 @@ AS_IF([test "x$ido_db_type" = xpgsql], [
ido_enabled="disable=1" ido_enabled="disable=1"
statusdat_enabled="disable=1" statusdat_enabled="disable=1"
livestatus_enabled="disable=1" livestatus_enabled="disable=1"
ldap_enabled="disable=1"
AS_CASE([$icinga_backend], AS_CASE([$icinga_backend],
["ido"], [ido_enabled=""], ["ido"], [ido_enabled=""],
@ -354,9 +353,16 @@ AS_CASE([$icinga_backend],
["livestatus"], [livestatus_enabled=""], ["livestatus"], [livestatus_enabled=""],
[statusdat_enabled=""]) [statusdat_enabled=""])
use_ldap_auth=";"
AS_IF([test "x$ldap_authentication" != xno], AS_IF([test "x$ldap_authentication" != xno],
AC_CHECK_PHP_MODULE([ldap]) AC_CHECK_PHP_MODULE([ldap])
ldap_enabled="" use_ldap_auth=""
)
use_internal_auth=";"
AS_IF([test "x$internal_authentication" != xno],
AC_CHECK_PHP_MODULE([ldap])
use_internal_auth=""
) )
# #
@ -416,58 +422,9 @@ AC_SUBST(livestatus_socket)
AC_SUBST(icinga_commandpipe) AC_SUBST(icinga_commandpipe)
# Comment placeholders for toggling backends # Comment placeholders for toggling backends
AC_SUBST(livestatus_enabled)
AC_SUBST(statusdat_enabled)
AC_SUBST(ido_enabled)
AC_SUBST(ldap_enabled)
# Internal db setup AC_SUBST(use_ldap_auth)
AC_SUBST(internal_db_type) AC_SUBST(use_internal_auth)
AC_SUBST(internal_db_name)
AC_SUBST(internal_db_host)
AC_SUBST(internal_db_port)
AC_SUBST(internal_db_user)
AC_SUBST(internal_db_pass)
# ldap setup
AC_SUBST(ldap_host)
AC_SUBST(ldap_port)
AC_SUBST(ldap_rootdn)
AC_SUBST(ldap_binddn)
AC_SUBST(ldap_bindpass)
AC_SUBST(ldap_user_objectclass)
AC_SUBST(ldap_attribute_basedn)
AC_SUBST(ldap_attribute_username)
AC_SUBST(ldap_attribute_password)
AC_SUBST(ldap_group_objectclass)
AC_SUBST(ldap_attribute_groupname)
# backend setup
AC_SUBST(icinga_backend)
# ido backend variables
AC_SUBST(ido_db_type)
AC_SUBST(ido_host)
AC_SUBST(ido_port)
AC_SUBST(ido_database)
AC_SUBST(ido_user)
AC_SUBST(ido_password)
# status.dat backend
AC_SUBST(statusdat_file)
AC_SUBST(objects_cache_file)
# livestatus backend
AC_SUBST(livestatus_socket)
# command pipe
AC_SUBST(icinga_commandpipe)
# Comment placeholders for toggling backends
AC_SUBST(livestatus_enabled)
AC_SUBST(statusdat_enabled)
AC_SUBST(ido_enabled)
AC_SUBST(ldap_enabled)
# Application and installation # Application and installation
AC_SUBST(PHP) AC_SUBST(PHP)
@ -483,6 +440,7 @@ AC_CONFIG_FILES([
config/resources.ini config/resources.ini
config/modules/monitoring/backends.ini config/modules/monitoring/backends.ini
etc/apache/icingaweb.conf etc/apache/icingaweb.conf
public/.htaccess
]) ])
# #

View File

@ -147,6 +147,4 @@ class Config extends Zend_Config_Ini
{ {
return $this->configFile; return $this->configFile;
} }
} }

View File

@ -206,6 +206,14 @@ class DbUserBackend implements UserBackend
return $usr; return $usr;
} }
/**
* Return the number of users in this database connection
*
* This class is mainly used for determining whether the authentication backend is valid or not
*
* @return int The number of users set in this backend
* @see UserBackend::getUserCount
*/
public function getUserCount() public function getUserCount()
{ {

View File

@ -122,8 +122,7 @@ class LdapUserBackend implements UserBackend
if (!$this->connection->testCredentials( if (!$this->connection->testCredentials(
$this->connection->fetchDN($this->selectUsername($credentials->getUsername())), $this->connection->fetchDN($this->selectUsername($credentials->getUsername())),
$credentials->getPassword() $credentials->getPassword()
) )) {
) {
return false; return false;
} }
$user = new User($credentials->getUsername()); $user = new User($credentials->getUsername());
@ -131,7 +130,8 @@ class LdapUserBackend implements UserBackend
return $user; return $user;
} }
public function getUserCount() { public function getUserCount()
{
return $this->connection->count( return $this->connection->count(
$this->connection->select()->from( $this->connection->select()->from(
$this->config->user_class, $this->config->user_class,

View File

@ -28,6 +28,9 @@
namespace Icinga\Authentication; namespace Icinga\Authentication;
/**
* Interface for backends that authenticate users
*/
interface UserBackend interface UserBackend
{ {
/** /**

View File

@ -162,7 +162,8 @@ class Form extends Zend_Form
* Add elements to this form (used by extending classes) * Add elements to this form (used by extending classes)
*/ */
protected function create() protected function create()
{} {
}
/** /**
* Method called before validation * Method called before validation

View File

@ -70,6 +70,7 @@ class Monitoring_ConfigController extends BaseConfigController {
{ {
$this->view->backends = IcingaConfig::module('monitoring', 'backends')->toArray(); $this->view->backends = IcingaConfig::module('monitoring', 'backends')->toArray();
$this->view->instances = IcingaConfig::module('monitoring', 'instances')->toArray(); $this->view->instances = IcingaConfig::module('monitoring', 'instances')->toArray();
$this->render('index');
} }
/** /**
@ -114,11 +115,12 @@ class Monitoring_ConfigController extends BaseConfigController {
$configArray[$form->getBackendName()] = $form->getConfig(); $configArray[$form->getBackendName()] = $form->getConfig();
if ($this->writeConfiguration(new Zend_Config($configArray), 'backends')) { if ($this->writeConfiguration(new Zend_Config($configArray), 'backends')) {
$this->redirectNow('monitoring/config'); $this->view->successMessage = 'Backend Creation Succeeded';
$this->indexAction();
} else { } else {
$this->render('show-configuration'); $this->render('show-configuration');
return;
} }
return;
} }
$this->view->form = $form; $this->view->form = $form;
$this->render('editbackend'); $this->render('editbackend');
@ -143,11 +145,12 @@ class Monitoring_ConfigController extends BaseConfigController {
unset($configArray[$backend]); unset($configArray[$backend]);
if ($this->writeConfiguration(new Zend_Config($configArray), 'backends')) { if ($this->writeConfiguration(new Zend_Config($configArray), 'backends')) {
$this->redirectNow('monitoring/config'); $this->view->successMessage = 'Backend "' . $backend . '" Removed';
$this->indexAction();
} else { } else {
$this->render('show-configuration'); $this->render('show-configuration');
return;
} }
return;
} }
$this->view->form = $form; $this->view->form = $form;
@ -174,11 +177,12 @@ class Monitoring_ConfigController extends BaseConfigController {
unset($configArray[$instance]); unset($configArray[$instance]);
if ($this->writeConfiguration(new Zend_Config($configArray), 'instances')) { if ($this->writeConfiguration(new Zend_Config($configArray), 'instances')) {
$this->redirectNow('monitoring/config'); $this->view->successMessage = 'Instance "' . $instance . '" Removed';
$this->indexAction();
} else { } else {
$this->render('show-configuration'); $this->render('show-configuration');
return;
} }
return;
} }
$this->view->form = $form; $this->view->form = $form;
@ -202,7 +206,8 @@ class Monitoring_ConfigController extends BaseConfigController {
$instanceConfig = IcingaConfig::module('monitoring', 'instances')->toArray(); $instanceConfig = IcingaConfig::module('monitoring', 'instances')->toArray();
$instanceConfig[$instance] = $form->getConfig(); $instanceConfig[$instance] = $form->getConfig();
if ($this->writeConfiguration(new Zend_Config($instanceConfig), 'instances')) { if ($this->writeConfiguration(new Zend_Config($instanceConfig), 'instances')) {
$this->redirectNow('monitoring/config'); $this->view->successMessage = 'Instance Modified';
$this->indexAction();
} else { } else {
$this->render('show-configuration'); $this->render('show-configuration');
return; return;
@ -222,11 +227,12 @@ class Monitoring_ConfigController extends BaseConfigController {
$instanceConfig = IcingaConfig::module('monitoring', 'instances')->toArray(); $instanceConfig = IcingaConfig::module('monitoring', 'instances')->toArray();
$instanceConfig[$form->getInstanceName()] = $form->getConfig()->toArray(); $instanceConfig[$form->getInstanceName()] = $form->getConfig()->toArray();
if ($this->writeConfiguration(new Zend_Config($instanceConfig), 'instances')) { if ($this->writeConfiguration(new Zend_Config($instanceConfig), 'instances')) {
$this->redirectNow('monitoring/config'); $this->view->successMessage = 'Instance Creation Succeeded';
$this->indexAction();
} else { } else {
$this->render('show-configuration'); $this->render('show-configuration');
return;
} }
return;
} }
$this->view->form = $form; $this->view->form = $form;
$this->render('editinstance'); $this->render('editinstance');

View File

@ -3,6 +3,13 @@
<h3>Monitoring Backends</h3> <h3>Monitoring Backends</h3>
<?php if ($this->successMessage): ?>
<div class="alert alert-success">
<i>{{OK_ICON}}</i>
<strong><?= $this->escape($this->successMessage); ?></strong>
</div>
<?php endif; ?>
<div> <div>
<a href="<?= Url::fromPath('/monitoring/config/createbackend')->getAbsoluteUrl();?>"> <a href="<?= Url::fromPath('/monitoring/config/createbackend')->getAbsoluteUrl();?>">
{{CREATE_ICON}} Create New Monitoring Backend {{CREATE_ICON}} Create New Monitoring Backend

14
public/.htaccess.in Normal file
View File

@ -0,0 +1,14 @@
SetEnv APPLICATION_ENV development
RewriteEngine on
RewriteBase @web_path@
RewriteRule ^css/icinga.css css.php
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
php_flag short_open_tag on
php_value xdebug.idekey PHPSTORM

View File

@ -73,15 +73,15 @@ if (path === null) {
var startFromBase = function(url, then) { var startFromBase = function(url, then) {
return cstart.call(casper, this.getBaseURL(url), then); return cstart.call(casper, getBaseURL(url), then);
}; };
var thenOpenFromBase = function(url, options) { var thenOpenFromBase = function(url, options) {
return cthenOpen.apply(casper, [this.getBaseURL(url), options]); return cthenOpen.apply(casper, [getBaseURL(url), options]);
}; };
var openFromBase = function(url, options) { var openFromBase = function(url, options) {
return copen.apply(casper, [this.getBaseURL(url), options]); return copen.apply(casper, [getBaseURL(url), options]);
}; };
casper.on('remote.message', function(message) { casper.on('remote.message', function(message) {
@ -109,7 +109,7 @@ if (path === null) {
}; };
exports.performLogin = function() { exports.performLogin = function() {
casper.open("/authentication/logou", function() { casper.start("/authentication/login", function() {
this.fill('form#login', icinga.getCredentials()); this.fill('form#login', icinga.getCredentials());
this.click('form#login input#submit'); this.click('form#login input#submit');
}); });

View File

@ -0,0 +1,134 @@
/**
* Configuration: Show message that changes were saved successfully
*
* As a user I want too see that configuration changes were successful.
*
* This test performs the following steps
*
* - Login using the provided credentials
* - Open the configuration dialog and change the timezone
* - Save and test for a success bubble to appear
* - Open the authentication dialog
* - Open the edit link of the first backend
* - Hit save and test for a success bubble to apper
* - Open the logging dialog, hit save and test for a success bubble to appear
**/
/**
* The icinga util object
*
* @type object
*/
var icinga = require('./icingawebtest');
/**
* The casperjs object
*
* @type Casper
*/
var casper = icinga.getTestEnv();
/**
* Login to the instance
*/
icinga.performLogin();
/**
* Open the config dialog and test if the form exists
*/
casper.thenOpen('/config', function() {
this.test.assertExists(
'#form_config_general',
'Test whether the general settings dialog exists in the general form'
);
this.test.assertExists(
'#form_config_general select#timezone',
'Assert the timezone input to exist'
);
});
/**
* Change the timezone and submit
*/
casper.then(function() {
this.test.assertDoesntExist(
'div.alert.alert-success',
'Assert no success notice existing when no changes have been done in the general form'
);
this.fill('#form_config_general', {
'timezone': 'Europe/Minsk'
});
this.click('#form_config_general input#btn_submit');
});
/**
* Check for the 'Successfully Update' information bubble
*/
casper.then(function() {
this.waitForSelector('div.alert.alert-success', function() {
this.test.assertSelectorHasText(
'div.alert.alert-success',
'Config Sucessfully Updated',
'Assert a success text to appear in the general form'
);
}, function() {
this.die("No success text appeared in the general form");
});
});
/**
* Open the config dialog and click on the first 'Edit This Authentication Backend' Link
*/
casper.thenOpen('/config/authentication', function() {
var link = this.evaluate(function() {
var links = document.querySelectorAll('#icingamain a');
for (var i=0; i<links.length; i++) {
if (/.* Edit This Authentication/.test(links[i].text)) {
document.location.href = links[i].getAttribute('href');
}
}
});
});
/**
* Submit the authenticaton backend without any changes and test for the success bubble
*/
casper.then(function() {
this.waitForSelector('input#btn_submit', function() {
this.click('input#btn_submit');
this.waitForSelector('div.alert.alert-success', function() {
this.test.assertExists('div.alert.alert-success', 'Assert a success message to exist');
}, function() {
this.die("Success message for authentication provider tests didn't pop up");
});
}, function() {
this.die('No submit button found when expected the "Edit this authentication provider" form');
});
});
/**
* Submit the logging dialog without any changes and test for the success bubble
*/
casper.thenOpen('/config/logging', function() {
this.test.assertExists('form#form_config_logging', 'Asserting the logging form to exist');
this.click('form#form_config_logging input#btn_submit');
this.echo("Submitting authentication form1");
this.waitForSelector('div.alert.alert-success', function() {
this.test.assertExists('div.alert.alert-success', 'Assert a success message to exist');
}, function() {
this.die('No success message popped up when saving logging configuration');
});
this.echo("Submitting authentication form2");
});
/**
* Run the tests
*/
casper.run(function() {
this.test.done();
});