From 09ca80c3f48b5f538185438c0ccc93b0fd190eca Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Tue, 8 Aug 2017 17:50:36 +0200 Subject: [PATCH] Feature service configuration (#5482) * New Features began * File updated" * File finished' * File updated * * #5497 duplicate acl --- behat.yml | 20 +- features/ServiceConfiguration.feature | 20 + .../bootstrap/ServiceConfigurationContext.php | 447 ++++++++++++++++++ 3 files changed, 482 insertions(+), 5 deletions(-) create mode 100644 features/ServiceConfiguration.feature create mode 100644 features/bootstrap/ServiceConfigurationContext.php diff --git a/behat.yml b/behat.yml index ea126e8a0cb..48d2aea639a 100644 --- a/behat.yml +++ b/behat.yml @@ -179,11 +179,6 @@ default: contexts: - ContactConfigurationContext - contact_group_configuration: - paths: [ %paths.base%/features/ContactGroupConfiguration.feature ] - contexts: - - ContactGroupConfigurationContext - host_configuration: paths: [ %paths.base%/features/HostConfiguration.feature ] contexts: @@ -199,6 +194,16 @@ default: contexts: - HostGroupConfigurationContext + contact_group_configuration: + paths: [ %paths.base%/features/ContactGroupConfiguration.feature ] + contexts: + - ContactGroupConfigurationContext + + contact_group_creation_duplication: + paths: [ %paths.base%/features/ContactGroupCreationDuplication.feature ] + contexts: + - ContactGroupCreationDuplicationContext + ldap_configuration: paths: [ %paths.base%/features/LdapConfiguration.feature ] contexts: @@ -279,6 +284,11 @@ default: contexts: - ServiceGroupConfigurationContext + service_configuration: + paths: [ %paths.base%/features/ServiceConfiguration.feature ] + contexts: + - ServiceConfigurationContext + host_group_service_configuration: paths: [ %paths.base%/features/HostGroupServiceConfiguration.feature ] contexts: diff --git a/features/ServiceConfiguration.feature b/features/ServiceConfiguration.feature new file mode 100644 index 00000000000..35187ad4890 --- /dev/null +++ b/features/ServiceConfiguration.feature @@ -0,0 +1,20 @@ +Feature: Edit a service + As a Centreon user + I want to manipulate a service + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a service is configured + + Scenario: Change the properties of a service + When I change the properties of a service + Then the properties are updated + + Scenario: Duplicate one existing service + When I duplicate a service + Then the new service has the same properties + + Scenario: Delete one existing service + When I delete a service + Then the deleted service is not displayed in the service list diff --git a/features/bootstrap/ServiceConfigurationContext.php b/features/bootstrap/ServiceConfigurationContext.php new file mode 100644 index 00000000000..2e399bfdd0c --- /dev/null +++ b/features/bootstrap/ServiceConfigurationContext.php @@ -0,0 +1,447 @@ + 'hostName', + 'alias' => 'hostAlias', + 'address' => 'host@localhost' + ); + + protected $serviceCategory1 = array( + 'name' => 'serviceCategory1Name', + 'description' => 'serviceCategory1Description', + 'severity' => 1, + 'level' => 3, + 'icon' => ' centreon (png)' + ); + + protected $serviceCategory2 = array( + 'name' => 'serviceCategory2Name', + 'description' => 'serviceCategory2Description', + 'severity' => 1, + 'level' => 2, + 'icon' => ' centreon (png)' + ); + + protected $serviceGroup1 = array( + 'name' => 'serviceGroup1Name', + 'description' => 'serviceGroup1Description' + ); + + protected $serviceGroup2 = array( + 'name' => 'serviceGroup2Name', + 'description' => 'serviceGroup2Description' + ); + + protected $initialProperties = array( + 'hosts' => 'Centreon-Server', + 'description' => 'serviceDescription', + 'templates' => 'generic-service', + 'check_command' => 'check_http', + 'macros' => array( + 'MACRONAME' => 22 + ), + 'check_period' => 'workhours', + 'max_check_attempts' => 15, + 'normal_check_interval' => 7, + 'retry_check_interval' => 9, + 'active_checks_enabled' => 2, + 'passive_checks_enabled' => 1, + 'is_volatile' => 0, + 'notifications_enabled' => 2, + 'inherits_contacts_groups' => 0, + 'contacts' => 'Guest', + 'contact_additive_inheritance' => 1, + 'contact_groups' => 'Supervisors', + 'contact_group_additive_inheritance' => 1, + 'notification_interval' => 23, + 'notify_on_none' => 1, + 'notify_on_warning' => 0, + 'notify_on_unknown' => 0, + 'notify_on_critical' => 0, + 'notify_on_recovery' => 0, + 'notify_on_flapping' => 0, + 'notify_on_downtime_scheduled' => 0, + 'first_notification_delay' => 4, + 'recovery_notification_delay' => 3, + 'service_groups' => 'serviceGroup1Name', + 'trap_relations' => 'Generic - coldStart', + 'obsess_over_service' => 2, + 'acknowledgement_timeout' => 34, + 'check_freshness' => 1, + 'freshness_threshold' => 22, + 'flap_detection_enabled' => 0, + 'low_flap_threshold' => 15, + 'high_flap_threshold' => 18, + 'retain_status_information' => 2, + 'retain_non_status_information' => 1, + 'stalking_on_ok' => 1, + 'stalking_on_warning' => 1, + 'stalking_on_unknown' => 0, + 'stalking_on_critical' => 0, + 'event_handler_enabled' => 0, + 'event_handler' => 'check_https', + 'event_handler_arguments' => 'eventHandlerArgument', + 'graph_template' => 'CPU', + 'service_categories' => 'Disk', + 'url' => 'serviceUrl', + 'notes' => 'serviceNotes', + 'action_url' => 'serviceActionUrl', + 'icon' => ' centreon (png)', + 'alt_icon' => 'serviceAltIcon', + 'severity' => 'serviceCategory2Name (2)', + 'geo_coordinates' => 'Paris', + 'status' => 1, + 'comments' => 'serviceComments' + ); + + protected $duplicatedProperties = array( + 'hosts' => 'Centreon-Server', + 'description' => 'serviceDescription_1', + 'templates' => 'generic-service', + 'check_command' => 'check_http', + 'macros' => array( + 'MACRONAME' => 22 + ), + 'check_period' => 'workhours', + 'max_check_attempts' => 15, + 'normal_check_interval' => 7, + 'retry_check_interval' => 9, + 'active_checks_enabled' => 2, + 'passive_checks_enabled' => 1, + 'is_volatile' => 0, + 'notifications_enabled' => 2, + 'inherits_contacts_groups' => 0, + 'contacts' => 'Guest', + 'contact_additive_inheritance' => 1, + 'contact_groups' => 'Supervisors', + 'contact_group_additive_inheritance' => 1, + 'notification_interval' => 23, + 'notify_on_none' => 1, + 'notify_on_warning' => 0, + 'notify_on_unknown' => 0, + 'notify_on_critical' => 0, + 'notify_on_recovery' => 0, + 'notify_on_flapping' => 0, + 'notify_on_downtime_scheduled' => 0, + 'first_notification_delay' => 4, + 'recovery_notification_delay' => 3, + 'service_groups' => 'serviceGroup1Name', + 'trap_relations' => 'coldStart', + 'obsess_over_service' => 2, + 'acknowledgement_timeout' => 34, + 'check_freshness' => 1, + 'freshness_threshold' => 22, + 'flap_detection_enabled' => 0, + 'low_flap_threshold' => 15, + 'high_flap_threshold' => 18, + 'retain_status_information' => 2, + 'retain_non_status_information' => 1, + 'stalking_on_ok' => 1, + 'stalking_on_warning' => 1, + 'stalking_on_unknown' => 0, + 'stalking_on_critical' => 0, + 'event_handler_enabled' => 0, + 'event_handler' => 'check_https', + 'event_handler_arguments' => 'eventHandlerArgument', + 'graph_template' => 'CPU', + 'service_categories' => 'Disk', + 'url' => 'serviceUrl', + 'notes' => 'serviceNotes', + 'action_url' => 'serviceActionUrl', + 'icon' => ' centreon (png)', + 'alt_icon' => 'serviceAltIcon', + 'severity' => 'serviceCategory2Name (2)', + 'geo_coordinates' => 'Paris', + 'status' => 1, + 'comments' => 'serviceComments' + ); + + protected $update = array( + 'hosts' => 'hostName', + 'description' => 'serviceDescriptionChanged', + 'templates' => 'Ping-WAN', + 'check_command' => 'check_https', + 'macros' => array( + 'MACRONAMECHANGED' => 11 + ), + 'check_period' => 'none', + 'max_check_attempts' => 32, + 'normal_check_interval' => 81, + 'retry_check_interval' => 12, + 'active_checks_enabled' => 0, + 'passive_checks_enabled' => 2, + 'is_volatile' => 1, + 'notifications_enabled' => 0, + 'inherits_contacts_groups' => 1, + 'notification_interval' => 14, + 'notify_on_none' => 0, + 'notify_on_warning' => 1, + 'notify_on_unknown' => 1, + 'notify_on_critical' => 1, + 'notify_on_recovery' => 1, + 'notify_on_flapping' => 1, + 'notify_on_downtime_scheduled' => 1, + 'first_notification_delay' => 8, + 'recovery_notification_delay' => 9, + 'service_groups' => 'serviceGroup2Name', + 'trap_relations' => 'HP - snTrapL4GslbRemoteControllerUp', + 'obsess_over_service' => 0, + 'acknowledgement_timeout' => 28, + 'check_freshness' => 2, + 'freshness_threshold' => 31, + 'flap_detection_enabled' => 1, + 'low_flap_threshold' => 42, + 'high_flap_threshold' => 79, + 'retain_status_information' => 1, + 'retain_non_status_information' => 0, + 'stalking_on_ok' => 0, + 'stalking_on_warning' => 0, + 'stalking_on_unknown' => 1, + 'stalking_on_critical' => 1, + 'event_handler_enabled' => 1, + 'event_handler' => 'check_http', + 'event_handler_arguments' => 'eventHandlerArgumentChanged', + 'graph_template' => 'Storage', + 'service_categories' => 'Memory', + 'url' => 'serviceUrlChanged', + 'notes' => 'serviceNotesChanged', + 'action_url' => 'serviceActionUrlChanged', + 'icon' => '', + 'alt_icon' => 'Empty', + 'severity' => 'serviceCategory1Name (3)', + 'geo_coordinates' => '1.2.3.4', + 'status' => 1, + 'comments' => 'serviceCommentsChanged' + ); + + protected $updatedProperties = array( + 'hosts' => 'hostName', + 'description' => 'serviceDescriptionChanged', + 'templates' => 'Ping-WAN', + 'check_command' => 'check_https', + 'macros' => array( + 'MACRONAMECHANGED' => 11, + 'MACRONAME' => 22 + ), + 'check_period' => 'none', + 'max_check_attempts' => 32, + 'normal_check_interval' => 81, + 'retry_check_interval' => 12, + 'active_checks_enabled' => 0, + 'passive_checks_enabled' => 2, + 'is_volatile' => 1, + 'notifications_enabled' => 0, + 'inherits_contacts_groups' => 1, + 'contacts' => '', + 'contact_additive_inheritance' => 0, + 'contact_groups' => '', + 'contact_group_additive_inheritance' => 0, + 'notification_interval' => 14, + 'notify_on_none' => 0, + 'notify_on_warning' => 1, + 'notify_on_unknown' => 1, + 'notify_on_critical' => 1, + 'notify_on_recovery' => 1, + 'notify_on_flapping' => 1, + 'notify_on_downtime_scheduled' => 1, + 'first_notification_delay' => 8, + 'recovery_notification_delay' => 9, + 'service_groups' => 'serviceGroup2Name', + 'trap_relations' => array( + 'snTrapL4GslbRemoteControllerUp' + ), + 'obsess_over_service' => 0, + 'acknowledgement_timeout' => 28, + 'check_freshness' => 2, + 'freshness_threshold' => 31, + 'flap_detection_enabled' => 1, + 'low_flap_threshold' => 42, + 'high_flap_threshold' => 79, + 'retain_status_information' => 1, + 'retain_non_status_information' => 0, + 'stalking_on_ok' => 0, + 'stalking_on_warning' => 0, + 'stalking_on_unknown' => 1, + 'stalking_on_critical' => 1, + 'event_handler_enabled' => 1, + 'event_handler' => 'check_http', + 'event_handler_arguments' => 'eventHandlerArgumentChanged', + 'graph_template' => 'Storage', + 'service_categories' => 'Memory', + 'url' => 'serviceUrlChanged', + 'notes' => 'serviceNotesChanged', + 'action_url' => 'serviceActionUrlChanged', + 'icon' => '', + 'alt_icon' => 'Empty', + 'severity' => 'serviceCategory1Name (3)', + 'geo_coordinates' => '1.2.3.4', + 'status' => 1, + 'comments' => 'serviceCommentsChanged' + ); + + /** + * @Given a service is configured + */ + public function aServiceIsConfigured() + { + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host); + $this->currentPage->save(); + $this->currentPage = new ServiceCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->serviceCategory1); + $this->currentPage->save(); + $this->currentPage = new ServiceCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->serviceCategory2); + $this->currentPage->save(); + $this->currentPage = new ServiceGroupConfigurationPage($this); + $this->currentPage->setProperties($this->serviceGroup1); + $this->currentPage->save(); + $this->currentPage = new ServiceGroupConfigurationPage($this); + $this->currentPage->setProperties($this->serviceGroup2); + $this->currentPage->save(); + $this->currentPage = new ServiceConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a service + */ + public function iChangeThePropertiesOfAService() + { + $this->currentPage = new ServiceConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['description']); + $this->currentPage->setProperties($this->update); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ServiceConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['description']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a service + */ + public function iDuplicateAService() + { + $this->currentPage = new ServiceConfigurationListingPage($this); + $object = $this->currentPage->getEntry(array( + 'service' => $this->initialProperties['description'], + 'host' => $this->initialProperties['hosts'] + )); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new service has the same properties + */ + public function theNewServiceHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ServiceConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->duplicatedProperties['description']); + $object = $this->currentPage->getProperties(); + foreach ($this->duplicatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a service + */ + public function iDeleteAService() + { + $this->currentPage = new ServiceConfigurationListingPage($this); + $object = $this->currentPage->getEntry(array( + 'service' => $this->initialProperties['description'], + 'host' => $this->initialProperties['hosts'] + )); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted service is not displayed in the service list + */ + public function theDeletedServiceIsNotDisplayedInTheServiceList() + { + $this->spin( + function ($context) { + $this->currentPage = new ServiceConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $host => $service) { + foreach ($service as $value) { + $bool = $bool && $value['service'] != $this->initialProperties['description']; + } + } + return $bool; + }, + "The service is not being deleted.", + 5 + ); + } +}