diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index 3c939ac9c..9bc7d8381 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -101,7 +101,9 @@ class ConfigController extends BaseConfigController if (!$this->writeConfigFile($form->getConfig(), 'config')) { return; } - $this->redirectNow('/config'); + $this->view->successMessage = "Config Sucessfully Updated"; + $form->setConfiguration(IcingaConfig::app(), true); + } $this->view->form = $form; } @@ -116,11 +118,11 @@ class ConfigController extends BaseConfigController $form->setConfiguration(IcingaConfig::app()); $form->setRequest($this->_request); if ($form->isSubmittedAndValid()) { - $config = $form->getConfig(); if (!$this->writeConfigFile($form->getConfig(), 'config')) { return; } - $this->redirectNow('/config/logging'); + $this->view->successMessage = "Config Sucessfully Updated"; + $form->setConfiguration(IcingaConfig::app(), true); } $this->view->form = $form; } @@ -141,10 +143,12 @@ class ConfigController extends BaseConfigController */ public function moduleenableAction() { + $module = $this->_getParam('name'); $manager = Icinga::app()->getModuleManager(); - $manager->enableModule($this->_getParam('name')); - $manager->loadModule($this->_getParam('name')); - $this->redirectNow('config/moduleoverview?_render=body'); + $manager->enableModule($module); + $manager->loadModule($module); + $this->view->successMessage = 'Module "' . $module . '" enabled'; + $this->moduleoverviewAction(); } /** @@ -152,9 +156,11 @@ class ConfigController extends BaseConfigController */ public function moduledisableAction() { + $module = $this->_getParam('name'); $manager = Icinga::app()->getModuleManager(); - $manager->disableModule($this->_getParam('name')); - $this->redirectNow('config/moduleoverview?_render=body'); + $manager->disableModule($module); + $this->view->successMessage = 'Module "' . $module . '" disabled'; + $this->moduleoverviewAction(); } /** diff --git a/application/forms/Config/Authentication/BaseBackendForm.php b/application/forms/Config/Authentication/BaseBackendForm.php index da04011fd..799b86af8 100644 --- a/application/forms/Config/Authentication/BaseBackendForm.php +++ b/application/forms/Config/Authentication/BaseBackendForm.php @@ -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( array( '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 * skip the logic connection validation. @@ -165,7 +165,7 @@ abstract class BaseBackendForm extends Form if ($this->getRequest()->getPost('backend_force_creation')) { return true; } - if(!$this->validateAuthenticationBackend()) { + if (!$this->isValidAuthenticationBackend()) { $this->addForceCreationCheckbox(); return false; } @@ -188,5 +188,5 @@ abstract class BaseBackendForm extends Form * * @return bool True when validation succeeded, otherwise false */ - abstract public function validateAuthenticationBackend(); + abstract public function isValidAuthenticationBackend(); } diff --git a/application/forms/Config/Authentication/DbBackendForm.php b/application/forms/Config/Authentication/DbBackendForm.php index aa7d555a8..9bdebfcde 100644 --- a/application/forms/Config/Authentication/DbBackendForm.php +++ b/application/forms/Config/Authentication/DbBackendForm.php @@ -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 { $name = $this->getBackendName(); diff --git a/application/forms/Config/Authentication/LdapBackendForm.php b/application/forms/Config/Authentication/LdapBackendForm.php index 52705ca7a..e2ab898e4 100644 --- a/application/forms/Config/Authentication/LdapBackendForm.php +++ b/application/forms/Config/Authentication/LdapBackendForm.php @@ -164,20 +164,25 @@ class LdapBackendForm 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::isValidAuthenticationBacken + */ + public function isValidAuthenticationBackend() { try { $cfg = $this->getConfig(); + $backendName = 'backend_' . $this->filterName($this->getBackendName()) . '_name'; $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) { throw new Exception('No Users Found On Directory Server'); } - } catch(Exception $exc) { + } catch (Exception $exc) { $this->addErrorMessage( 'Connection Validation Failed:'. diff --git a/application/forms/Config/Authentication/ReorderForm.php b/application/forms/Config/Authentication/ReorderForm.php index 9a809536f..6bd4a4dd0 100644 --- a/application/forms/Config/Authentication/ReorderForm.php +++ b/application/forms/Config/Authentication/ReorderForm.php @@ -141,7 +141,7 @@ class ReorderForm extends Form ) ); } - $this->setAction(Url::fromPath("config/authentication",array())->getAbsoluteUrl()); + $this->setAction(Url::fromPath("config/authentication", array())->getAbsoluteUrl()); } /** @@ -162,7 +162,7 @@ class ReorderForm extends Form if (is_array($value)) { $result += $value; } else { - $result[$key] = $value; + $result[$key] = $value; } } return $result; diff --git a/application/forms/Config/GeneralForm.php b/application/forms/Config/GeneralForm.php index 031f0fdb5..406cee54c 100644 --- a/application/forms/Config/GeneralForm.php +++ b/application/forms/Config/GeneralForm.php @@ -322,7 +322,7 @@ class GeneralForm extends Form if ($preferences === null) { $preferences = new Zend_Config(array()); } - + $this->setName('form_config_general'); $this->addDevelopmentCheckbox($global); $this->addTimezoneSelection($global); $this->addModuleSettings($global); diff --git a/application/forms/Config/LoggingForm.php b/application/forms/Config/LoggingForm.php index 7528031f0..6183fc4c4 100644 --- a/application/forms/Config/LoggingForm.php +++ b/application/forms/Config/LoggingForm.php @@ -122,6 +122,7 @@ class LoggingForm extends Form */ public function create() { + $this->setName('form_config_logging'); if ($this->config === null) { $this->config = new Zend_Config(array()); } diff --git a/application/views/scripts/config/index.phtml b/application/views/scripts/config/index.phtml index f0b046499..603a496aa 100644 --- a/application/views/scripts/config/index.phtml +++ b/application/views/scripts/config/index.phtml @@ -1,2 +1,10 @@ tabs->render($this); ?> + +successMessage): ?> +
+ {{OK_ICON}} + escape($this->successMessage); ?> +
+ + form ?> \ No newline at end of file diff --git a/application/views/scripts/config/logging.phtml b/application/views/scripts/config/logging.phtml index 94f220abd..98766d479 100644 --- a/application/views/scripts/config/logging.phtml +++ b/application/views/scripts/config/logging.phtml @@ -2,6 +2,13 @@ form->getErrorMessages(); ?> +successMessage): ?> +
+ {{OK_ICON}} + escape($this->successMessage); ?> +
+ +

Errors occured when trying to save the project.

diff --git a/application/views/scripts/config/module/overview.phtml b/application/views/scripts/config/module/overview.phtml index 3ba07a2dc..652967b8d 100644 --- a/application/views/scripts/config/module/overview.phtml +++ b/application/views/scripts/config/module/overview.phtml @@ -8,6 +8,14 @@ $modules = $this->modules->paginate(); tabs->render($this); ?>

Installed Modules

+ +successMessage): ?> +
+ {{OK_ICON}} + escape($this->successMessage); ?> +
+ + paginationControl($modules, null, null, array( 'preserve' => $this->preserve )); diff --git a/config/authentication.ini.in b/config/authentication.ini.in index ce1bb3222..35c70c63f 100644 --- a/config/authentication.ini.in +++ b/config/authentication.ini.in @@ -1,24 +1,33 @@ -[ldap-authentication] -backend=ldap -hostname=@ldap_host@ -port=@ldap_port@ -root_dn='@ldap_rootdn@' -bind_dn='@ldap_binddn@' -bind_pw=@ldap_bindpass@ +; authentication.ini +; +; Each section listed in this configuration represents a single backend +; that can be used to authenticate users or groups. Each databse backend must refer +; to a resource defined in resources.ini, +; +; 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 -user.ldap_object_class=@ldap_user_objectclass@ -user.ldap_name_attribute=@ldap_attribute_username@ -user.password_attribute=@ldap_attribute_password@ -group.ldap_object_class=@ldap_group_objectclass@ -group.ldap_name_attribute=@ldap_attribute_groupname@ +@use_ldap_auth@user_class = "@ldap_user_objectclass@" +@use_ldap_auth@user_name_attribute = "@ldap_attribute_username@" +@use_ldap_auth@user_password_attribute = "@ldap_attribute_password@" -[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" diff --git a/config/resources.ini.in b/config/resources.ini.in index dedfa61b6..32514b84c 100644 --- a/config/resources.ini.in +++ b/config/resources.ini.in @@ -13,21 +13,13 @@ ; be interpreted. Currently only the resource type *db* is available. -[icingaweb-pgsql] +[internal_db] type = db -db = pgsql ; PostgreSQL -host = localhost -password = icinga -username = icingaweb -dbname = icingaweb - -[icingaweb-mysql] -type = db -db = mysql ; MySQL -host = localhost -password = icinga -username = icingaweb -dbname = icingaweb +db = @internal_db_type@ +host = @internal_db_host@ +password = @internal_db_password@ +username = @internal_db_user@ +dbname = @internal_db_database@ [ido] type = db diff --git a/configure b/configure index eab3b757e..37dff76ec 100755 --- a/configure +++ b/configure @@ -590,10 +590,8 @@ ac_subst_vars='LTLIBOBJS LIBOBJS INSTALL_OPTS_WEB INSTALL_OPTS -ldap_enabled -ido_enabled -statusdat_enabled -livestatus_enabled +use_internal_auth +use_ldap_auth icinga_commandpipe livestatus_socket objects_cache_file @@ -2400,7 +2398,7 @@ fi if test "${with_internal_authentication+set}" = set; then : withval=$with_internal_authentication; internal_authentication=yes else - internal_authentication=def + internal_authentication=yes fi @@ -2818,7 +2816,6 @@ fi ido_enabled="disable=1" statusdat_enabled="disable=1" livestatus_enabled="disable=1" -ldap_enabled="disable=1" case $icinga_backend in #( "ido") : @@ -2831,6 +2828,7 @@ case $icinga_backend in #( statusdat_enabled="" ;; esac +use_ldap_auth=";" if test "x$ldap_authentication" != xno; then : for x in ldap;do @@ -2844,7 +2842,25 @@ else fi 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 @@ -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 @@ -2966,7 +2933,7 @@ fi # # 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/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" ;; + "public/.htaccess") CONFIG_FILES="$CONFIG_FILES public/.htaccess" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac diff --git a/configure.ac b/configure.ac index 594f5feea..215dd0a51 100755 --- a/configure.ac +++ b/configure.ac @@ -126,7 +126,7 @@ AC_ARG_WITH([internal_db_user], AC_ARG_WITH([internal_authentication], AC_HELP_STRING([--with-internal-authentication], [use the internal database for authentication (default: yes)]), internal_authentication=yes, - internal_authentication=def + internal_authentication=yes ) AC_ARG_WITH([ldap_authentication], @@ -346,7 +346,6 @@ AS_IF([test "x$ido_db_type" = xpgsql], [ ido_enabled="disable=1" statusdat_enabled="disable=1" livestatus_enabled="disable=1" -ldap_enabled="disable=1" AS_CASE([$icinga_backend], ["ido"], [ido_enabled=""], @@ -354,9 +353,16 @@ AS_CASE([$icinga_backend], ["livestatus"], [livestatus_enabled=""], [statusdat_enabled=""]) +use_ldap_auth=";" AS_IF([test "x$ldap_authentication" != xno], 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) # 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(internal_db_type) -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) +AC_SUBST(use_ldap_auth) +AC_SUBST(use_internal_auth) # Application and installation AC_SUBST(PHP) @@ -483,6 +440,7 @@ AC_CONFIG_FILES([ config/resources.ini config/modules/monitoring/backends.ini etc/apache/icingaweb.conf + public/.htaccess ]) # diff --git a/library/Icinga/Application/Config.php b/library/Icinga/Application/Config.php index 339bb7293..7464b6003 100644 --- a/library/Icinga/Application/Config.php +++ b/library/Icinga/Application/Config.php @@ -143,10 +143,8 @@ class Config extends Zend_Config_Ini } } - public function getConfigFile() + public function getConfigFile() { return $this->configFile; } - - } diff --git a/library/Icinga/Authentication/Backend/DbUserBackend.php b/library/Icinga/Authentication/Backend/DbUserBackend.php index 0a9a6dbe6..149621784 100644 --- a/library/Icinga/Authentication/Backend/DbUserBackend.php +++ b/library/Icinga/Authentication/Backend/DbUserBackend.php @@ -206,6 +206,14 @@ class DbUserBackend implements UserBackend 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() { diff --git a/library/Icinga/Authentication/Backend/LdapUserBackend.php b/library/Icinga/Authentication/Backend/LdapUserBackend.php index a87da116b..ac5c3d07f 100644 --- a/library/Icinga/Authentication/Backend/LdapUserBackend.php +++ b/library/Icinga/Authentication/Backend/LdapUserBackend.php @@ -120,10 +120,9 @@ class LdapUserBackend implements UserBackend public function authenticate(Credentials $credentials) { if (!$this->connection->testCredentials( - $this->connection->fetchDN($this->selectUsername($credentials->getUsername())), - $credentials->getPassword() - ) - ) { + $this->connection->fetchDN($this->selectUsername($credentials->getUsername())), + $credentials->getPassword() + )) { return false; } $user = new User($credentials->getUsername()); @@ -131,7 +130,8 @@ class LdapUserBackend implements UserBackend return $user; } - public function getUserCount() { + public function getUserCount() + { return $this->connection->count( $this->connection->select()->from( $this->config->user_class, diff --git a/library/Icinga/Authentication/UserBackend.php b/library/Icinga/Authentication/UserBackend.php index 145f8ac36..6c5fe85d3 100644 --- a/library/Icinga/Authentication/UserBackend.php +++ b/library/Icinga/Authentication/UserBackend.php @@ -28,6 +28,9 @@ namespace Icinga\Authentication; +/** + * Interface for backends that authenticate users + */ interface UserBackend { /** @@ -59,4 +62,4 @@ interface UserBackend * @return int */ public function getUserCount(); -} +} \ No newline at end of file diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 23e85b39e..eddb70e88 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -162,7 +162,8 @@ class Form extends Zend_Form * Add elements to this form (used by extending classes) */ protected function create() - {} + { + } /** * Method called before validation diff --git a/modules/monitoring/application/controllers/ConfigController.php b/modules/monitoring/application/controllers/ConfigController.php index a0777ee46..76b12df08 100644 --- a/modules/monitoring/application/controllers/ConfigController.php +++ b/modules/monitoring/application/controllers/ConfigController.php @@ -70,6 +70,7 @@ class Monitoring_ConfigController extends BaseConfigController { { $this->view->backends = IcingaConfig::module('monitoring', 'backends')->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(); if ($this->writeConfiguration(new Zend_Config($configArray), 'backends')) { - $this->redirectNow('monitoring/config'); + $this->view->successMessage = 'Backend Creation Succeeded'; + $this->indexAction(); } else { $this->render('show-configuration'); - return; } + return; } $this->view->form = $form; $this->render('editbackend'); @@ -143,11 +145,12 @@ class Monitoring_ConfigController extends BaseConfigController { unset($configArray[$backend]); if ($this->writeConfiguration(new Zend_Config($configArray), 'backends')) { - $this->redirectNow('monitoring/config'); + $this->view->successMessage = 'Backend "' . $backend . '" Removed'; + $this->indexAction(); } else { $this->render('show-configuration'); - return; } + return; } $this->view->form = $form; @@ -174,11 +177,12 @@ class Monitoring_ConfigController extends BaseConfigController { unset($configArray[$instance]); if ($this->writeConfiguration(new Zend_Config($configArray), 'instances')) { - $this->redirectNow('monitoring/config'); + $this->view->successMessage = 'Instance "' . $instance . '" Removed'; + $this->indexAction(); } else { $this->render('show-configuration'); - return; } + return; } $this->view->form = $form; @@ -202,7 +206,8 @@ class Monitoring_ConfigController extends BaseConfigController { $instanceConfig = IcingaConfig::module('monitoring', 'instances')->toArray(); $instanceConfig[$instance] = $form->getConfig(); if ($this->writeConfiguration(new Zend_Config($instanceConfig), 'instances')) { - $this->redirectNow('monitoring/config'); + $this->view->successMessage = 'Instance Modified'; + $this->indexAction(); } else { $this->render('show-configuration'); return; @@ -222,11 +227,12 @@ class Monitoring_ConfigController extends BaseConfigController { $instanceConfig = IcingaConfig::module('monitoring', 'instances')->toArray(); $instanceConfig[$form->getInstanceName()] = $form->getConfig()->toArray(); if ($this->writeConfiguration(new Zend_Config($instanceConfig), 'instances')) { - $this->redirectNow('monitoring/config'); + $this->view->successMessage = 'Instance Creation Succeeded'; + $this->indexAction(); } else { $this->render('show-configuration'); - return; } + return; } $this->view->form = $form; $this->render('editinstance'); diff --git a/modules/monitoring/application/views/scripts/config/index.phtml b/modules/monitoring/application/views/scripts/config/index.phtml index 5ac7bdc9f..a12501f9f 100644 --- a/modules/monitoring/application/views/scripts/config/index.phtml +++ b/modules/monitoring/application/views/scripts/config/index.phtml @@ -3,6 +3,13 @@

Monitoring Backends

+successMessage): ?> +
+ {{OK_ICON}} + escape($this->successMessage); ?> +
+ +
{{CREATE_ICON}} Create New Monitoring Backend diff --git a/public/.htaccess.in b/public/.htaccess.in new file mode 100644 index 000000000..c6536f00d --- /dev/null +++ b/public/.htaccess.in @@ -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 diff --git a/test/frontend/icingawebtest.js b/test/frontend/icingawebtest.js index 08202ef70..26660e6ec 100644 --- a/test/frontend/icingawebtest.js +++ b/test/frontend/icingawebtest.js @@ -73,15 +73,15 @@ if (path === null) { 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) { - return cthenOpen.apply(casper, [this.getBaseURL(url), options]); + return cthenOpen.apply(casper, [getBaseURL(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) { @@ -109,7 +109,7 @@ if (path === null) { }; exports.performLogin = function() { - casper.open("/authentication/logou", function() { + casper.start("/authentication/login", function() { this.fill('form#login', icinga.getCredentials()); this.click('form#login input#submit'); }); diff --git a/test/frontend/regression/regression-4606.js b/test/frontend/regression/regression-4606.js new file mode 100644 index 000000000..67a7e6fcc --- /dev/null +++ b/test/frontend/regression/regression-4606.js @@ -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