This repository has been archived by the owner on Dec 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(traps): add SNMP trap group tests.
- Loading branch information
1 parent
4cce9ee
commit b83c870
Showing
3 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Feature: Edit a trap group | ||
As a Centreon user | ||
I want to manipulate a trap group | ||
To see if all simples manipulations work | ||
|
||
Background: | ||
Given I am logged in a Centreon server | ||
And a trap group is configured | ||
|
||
Scenario: Change the properties of a trap group | ||
When I change the properties of a trap group | ||
Then the properties are updated | ||
|
||
Scenario: Duplicate one existing trap group | ||
When I duplicate a trap group | ||
Then the new object has the same properties | ||
|
||
Scenario: Delete one existing trap group | ||
When I delete a trap group | ||
Then the deleted object is not displayed in the list |
114 changes: 114 additions & 0 deletions
114
features/bootstrap/TrapsSNMPGroupConfigurationContext.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?php | ||
|
||
use Centreon\Test\Behat\CentreonContext; | ||
use Centreon\Test\Behat\Configuration\SnmpTrapGroupConfigurationPage; | ||
use Centreon\Test\Behat\Configuration\SnmpTrapGroupConfigurationListingPage; | ||
|
||
class TrapsSNMPGroupConfigurationContext extends CentreonContext | ||
{ | ||
protected $currentPage; | ||
protected $initialProperties = array( | ||
'name' => 'trapGroupName', | ||
'traps' => array( | ||
'3com - secureViolation2', | ||
'Dell - adRebuildFailed' | ||
) | ||
); | ||
protected $updatedProperties = array( | ||
'name' => 'trapGroupNameChanged', | ||
'traps' => array( | ||
'Generic - coldStart', | ||
'HP - snTrapChasFanFailed' | ||
) | ||
); | ||
|
||
/** | ||
* @Given a trap group is configured | ||
*/ | ||
public function aTrapGroupIsConfigured() | ||
{ | ||
$this->currentPage = new SnmpTrapGroupConfigurationPage($this); | ||
$this->currentPage->setProperties($this->initialProperties); | ||
$this->currentPage->save(); | ||
} | ||
|
||
/** | ||
* @When I change the properties of a trap group | ||
*/ | ||
public function iChangeThePropertiesOfATrapGroup() | ||
{ | ||
$this->currentPage = new SnmpTrapGroupConfigurationListingPage($this); | ||
$this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); | ||
$this->currentPage->setProperties($this->updatedProperties); | ||
$this->currentPage->save(); | ||
} | ||
|
||
/** | ||
* @Then the properties are updated | ||
*/ | ||
public function thePropertiesAreUpdated() | ||
{ | ||
// No need to visit listing page, already loaded. | ||
$this->currentPage = new SnmpTrapGroupConfigurationListingPage($this, false); | ||
$this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); | ||
$object = $this->currentPage->getProperties(); | ||
foreach ($this->updatedProperties as $key => $value) { | ||
$expected = is_array($value) ? implode(' ', $value) : $value; | ||
if ($expected != $object[$key]) { | ||
throw new \Exception( | ||
'Property ' . $key . ' was not updated: got ' . | ||
$object[$key] . ', expected ' . $expected | ||
); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @When I duplicate a trap group | ||
*/ | ||
public function iDuplicateATrapGroup() | ||
{ | ||
$this->currentPage = new SnmpTrapGroupConfigurationListingPage($this); | ||
$object = $this->currentPage->getEntry($this->initialProperties['name']); | ||
$this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); | ||
$this->setConfirmBox(true); | ||
$this->selectInList('select[name="o1"]', 'Duplicate'); | ||
} | ||
|
||
/** | ||
* @Then the new object has the same properties | ||
*/ | ||
public function theNewObjectHasTheSameProperties() | ||
{ | ||
$this->updatedProperties = $this->initialProperties; | ||
$this->updatedProperties['name'] .= '_1'; | ||
$this->thePropertiesAreUpdated(); | ||
} | ||
|
||
/** | ||
* @When I delete a trap group | ||
*/ | ||
public function iDeleteATrapGroup() | ||
{ | ||
$this->currentPage = new SnmpTrapGroupConfigurationListingPage($this); | ||
$object = $this->currentPage->getEntry($this->initialProperties['name']); | ||
$this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); | ||
$this->setConfirmBox(true); | ||
$this->selectInList('select[name="o1"]', 'Delete'); | ||
} | ||
|
||
/** | ||
* @Then the deleted object is not displayed in the list | ||
*/ | ||
public function theDeletedObjectIsNotDisplayedInTheList() | ||
{ | ||
$this->currentPage = new SnmpTrapGroupConfigurationListingPage($this, false); | ||
$this->spin( | ||
function ($context) { | ||
$object = $context->currentPage->getEntries(); | ||
return !array_key_exists($context->initialProperties['name'], $object); | ||
}, | ||
'Service ' . $this->initialProperties['name'] . ' is not being deleted.' | ||
); | ||
} | ||
} |