Skip to content

Commit

Permalink
Merge pull request #14 from centreon/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
Jean-Baptiste authored Sep 22, 2017
2 parents fd0c5ac + 97f2d3f commit 40cfedf
Show file tree
Hide file tree
Showing 46 changed files with 708 additions and 359 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ They can be installed by following the [online installation guide](https://docum
## Bug report / Feature request

Bug reports and feature requests are more than welcome. However if you
wish to open a new issue, please read [this page](project/issues.md)
wish to open a new issue, please read [this page](project/creating-issue.md)
first.

## Coding Style Guide
Expand Down
4 changes: 4 additions & 0 deletions behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,7 @@ default:
meta_service_dependency_configuration:
paths: [ %paths.base%/features/MetaServiceDependencyConfiguration.feature ]
contexts: [ MetaServiceDependencyConfigurationContext ]

test_proxy_configuration:
paths: [ %paths.base%/features/TestProxyConfiguration.feature ]
contexts: [ TestProxyConfigurationContext ]
5 changes: 5 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ function loadDependencyInjector()
return new \Symfony\Component\Filesystem\Filesystem();
};

// Utils
$dependencyInjector['utils'] = function ($c) use ($dependencyInjector) {
return new \CentreonLegacy\Core\Utils\Utils($dependencyInjector);
};

// Define finder
$dependencyInjector['finder'] = $dependencyInjector->factory(function ($c) {
return new \Symfony\Component\Finder\Finder();
Expand Down
10 changes: 10 additions & 0 deletions doc/en/release_notes/centreon-2.8/centreon-2.8.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@ Centreon Web 2.8.13
Enhancements
============

* [Doc] Improve centreon documentation #5611 PR #5612
* [Doc] clarify documentation of centreon clapi authentication #5625 PR #5628
* [Performance] Correct svc top counter with meta and merge SQL requests PR #5616

Bugfix
======

* [Top Counter] Metaservices not counted properly in statuses filter #5458 PR #5616
* [Configuration] Properly export interval length in storage endpoints #5461
* [Documentation] Time Range exceptions invalid format #5578
* [Chart] No graphics with backslash #5554 #5342 PR #5565
* [LDAP] Problem with LDAP autoimport and groupmapping with comma in CN #4867
* [Monitoring] No inheritance in query of notified contacts (Monitoring view) #4981

10 changes: 10 additions & 0 deletions doc/en/release_notes/centreon-2.8/centreon-2.8.14.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
###################
Centreon Web 2.8.14
###################

Enhancements
============


Bugfix
======
1 change: 1 addition & 0 deletions doc/en/release_notes/centreon-2.8/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ Please find here the release notes dedicated to the last 2.8.x version of Centre
centreon-2.8.11
centreon-2.8.12
centreon-2.8.13
centreon-2.8.14
10 changes: 10 additions & 0 deletions doc/fr/release_notes/centreon-2.8/centreon-2.8.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@ Centreon Web 2.8.13
Enhancements
============

* [Doc] Improve centreon documentation #5611 PR #5612
* [Doc] clarify documentation of centreon clapi authentication #5625 PR #5628
* [Performance] Correct svc top counter with meta and merge SQL requests PR #5616

Bugfix
======

* [Top Counter] Metaservices not counted properly in statuses filter #5458 PR #5616
* [Configuration] Properly export interval length in storage endpoints #5461
* [Documentation] Time Range exceptions invalid format #5578
* [Chart] No graphics with backslash #5554 #5342 PR #5565
* [LDAP] Problem with LDAP autoimport and groupmapping with comma in CN #4867
* [Monitoring] No inheritance in query of notified contacts (Monitoring view) #4981

10 changes: 10 additions & 0 deletions doc/fr/release_notes/centreon-2.8/centreon-2.8.14.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
###################
Centreon Web 2.8.14
###################

Enhancements
============


Bugfix
======
1 change: 1 addition & 0 deletions doc/fr/release_notes/centreon-2.8/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ Please find here the release notes dedicated to the last 2.8.x version of Centre
centreon-2.8.11
centreon-2.8.12
centreon-2.8.13
centreon-2.8.14
14 changes: 14 additions & 0 deletions features/TestProxyConfiguration.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Feature: Testing A Configuration Proxy
As a Centreon user
I want to test my proxy configuration
So that to verify it

Scenario: Proxy settings with a correct connexion
Given I am logged in a Centreon server with a configured proxy
When I test the proxy configuration in the interface
Then a popin displays a successful connexion

Scenario: Proxy settings with a wrong connexion
Given I am logged in a Centreon server with a wrongly configured proxy
When I test the proxy configuration in the interface
Then a popin displays an error message
20 changes: 20 additions & 0 deletions features/bootstrap/InfluxdbContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,26 @@ public function anInfluxdbOutputIsProperlyConfigured()
)->setValue('value');

$this->assertFind('css', '#validForm > p:nth-child(1) > input:nth-child(1)')->click();

// Restart all pollers.
$this->restartAllPollers();

// Wait for the InfluxDB connection.
$this->spin(
function ($context) {
$retval = $context->container->execute(
'cat /var/lib/centreon-broker/central-broker-master-stats.json',
'web',
false
);
if ($retval['exit_code'] === 0) {
$stats = json_decode($retval['output'], true);
return $stats['endpoint TestInfluxdb']['state'] == 'connected';
}
return false;
},
'Centreon Broker did not connect to InfluxDB.'
);
}

/**
Expand Down
1 change: 0 additions & 1 deletion features/bootstrap/MassiveChangeHostsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class MassiveChangeHostsContext extends CentreonContext
'notify_on_downtime_scheduled' => 1,
'notify_on_none' => 0,
'notification_interval' => 17,
'update_mode_hcg' => 1,
'update_mode_notif_interval' => 0,
'update_mode_timeperiod' => 0,
'notification_period' => 'none',
Expand Down
74 changes: 74 additions & 0 deletions features/bootstrap/TestProxyConfigurationContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

use Centreon\Test\Behat\CentreonContext;
use Centreon\Test\Behat\Administration\ParametersCentreonUiPage;

class TestProxyConfigurationContext extends CentreonContext
{
private $page;
private $wrongProxyAddress = 'squad';
private $wrongProxyPort = '9999';

/**
* @When I test the proxy configuration in the interface
*/
public function ITestTheProxyConfigurationInTheInterface()
{
$this->visit('main.php?p=50110&o=general');
$this->assertFind('css', 'input[name="test_proxy"]')->click();
}

/**
* @Then a popin displays a successful connexion
*/
public function APopinDisplaysASuccessfulConnexion()
{
$this->spin(
function ($context) {
return $context->getSession()->getPage()->has(
'css',
'span[class="msg-field success2"]'
);
},
'The pop-in did not showed up'
);
$value = $this->assertFind('css', 'span[class="msg-field success2"]')->getText();
if ($value !== 'Connection Successful') {
throw new \Exception('The URL to reach failed');
}
}

/**
* @Given I am logged in a Centreon server with a wrongly configured proxy
*/
public function IAmLoggedInAcentreonServerWithAwronglyConfiguredProxy()
{
$this->iAmLoggedInACentreonServer();
$this->page = new ParametersCentreonUiPage($this);
$this->page->setProperties(array(
'proxy_url'=> $this->wrongProxyAddress,
'proxy_port'=> $this->wrongProxyPort
));
$this->page->save();
}

/**
* @Then a popin displays an error message
*/
public function aPopinDisplaysAnErrorMessage()
{
$this->spin(
function ($context) {
return $context->getSession()->getPage()->has(
'css',
'span[class="msg-field error"]'
);
},
'The pop-in did not showed up'
);
$value = $this->assertFind('css', 'span[class="msg-field error"]')->getText();
if ($value == 'Connection Successful') {
throw new \Exception('The Proxy configuration is incorrect');
}
}
}
46 changes: 41 additions & 5 deletions src/CentreonLegacy/Core/Utils/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function executeSqlFile($fileName, $customMacros = array(), $monitoring =
while (!feof($file)) {
$line = fgets($file);
if (!preg_match('/^(--|#)/', $line)) {

$pos = strrpos($line, ";");
$str .= $line;
if ($pos !== false) {
Expand Down Expand Up @@ -180,14 +180,50 @@ public function objectIntoArray($arrObjData, $skippedKeys = array())
}
return $arrData;
}

/**
*
* @param string $endPath
* @return string
* @param $endPath
* @return bool|string
*/
public function buildPath($endPath)
{
return realpath(__DIR__ . '/../../../../www/' . $endPath);
}

/**
* @param $password
* @param string $algo
* @return string
*/
public function encodePass($password, $algo = 'md5')
{
$encodePassword = '';
switch ($algo) {
case 'md5' :
$encodePassword .= 'md5__' . md5($password);
break;
case 'sha1' :
$encodePassword .= 'sha1__' . sha1($password);
break;
default :
$encodePassword .= 'md5__' . md5($password);
break;
}
return $encodePassword;
}

/**
* @param $pattern
* @return null
*/
public function detectPassPattern($pattern)
{
$patternData = explode('__', $pattern);
if (isset($patternData[1])) {
return $patternData[0];
} else {
return null;
}
}

}
41 changes: 29 additions & 12 deletions tests/rest_api/rest_api.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -1106,23 +1106,40 @@
"script": {
"type": "text/javascript",
"exec": [
"tests[\"Status code is 200\"] = responseCode.code === 200;",
"",
"var contentType = postman.getResponseHeader(\"Content-Type\");",
"",
"tests[\"Content-Type is present\"] = contentType !== null;",
"tests[\"Content-Type is application/json\"] = contentType === \"application/json\";",
"",
"var jsonData = JSON.parse(responseBody);",
"var hostData = jsonData.result;",
"",
"try {",
" tests[\"Body contains list of hosts\"] = hostData;",
" var i = 0;",
" while (i < hostData.length) {",
" if (postman.getEnvironmentVariable(\"instance_host\") == hostData[i].name) {",
" break;",
" }",
" i++;",
"tests[\"Body contains entries\"] = hostData.length > 0;",
"",
"var schema = 0;",
"if (hostData[0].id && hostData[0].name && hostData[0].address) {",
" schema = 1;",
"}",
"tests[\"Validate schema\"] = schema == 1;",
"",
"var pattern = /^_Module_/;",
"var hostMetaPresent = false;",
"var hostPresent = false;",
"",
"hostData.forEach(function(host) {",
" if (pattern.test(host.name) === true) {",
" hostMetaPresent = true;",
" }",
" tests[\"Body contains added host\"] = postman.getEnvironmentVariable(\"instance_host\") == hostData[i].generic-active-host;",
" tests[\"Body contains added host_address\"] = postman.getEnvironmentVariable(\"host_address\") == hostData[i]['0.0.0.1'];",
"} catch (e) {}",
" ",
" if ((host.name == postman.getEnvironmentVariable(\"host_name2\")) && (host.address == \"0.0.0.0\")) {",
" hostPresent = true;",
" }",
"});",
"",
"tests[\"Status code is 200\"] = responseCode.code === 200;"
"tests[\"Configured host present\"] = hostPresent === true;",
"tests[\"No _Module host present\"] = hostMetaPresent === false;"
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion www/api/class/centreon_monitoring_poller.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function getList()

$queryPoller = 'SELECT SQL_CALC_FOUND_ROWS DISTINCT instance_id, name ' .
'FROM instances ' .
'WHERE name LIKE :name ' .
'WHERE name LIKE :name AND deleted=0 ' .
'ORDER BY name ';
if (isset($this->arguments['page_limit']) && isset($this->arguments['page'])) {
$offset = ($this->arguments['page'] - 1) * $this->arguments['page_limit'];
Expand Down
29 changes: 29 additions & 0 deletions www/api/class/centreon_proxy.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

require_once dirname(__FILE__) . "/webService.class.php";
require_once _CENTREON_PATH_ . "/www/class/centreonRestHttp.class.php";

class CentreonProxy extends CentreonWebService
{
public function postCheckConfiguration()
{
$proxyAddress = $this->arguments['url'];
$proxyPort = $this->arguments['port'];
try {
$testUrl = 'http://ci.int.centreon.com:3000/api/pluginpack/pluginpack';
$restHttpLib = new \CentreonRestHttp();
$restHttpLib->setProxy($proxyAddress, $proxyPort);
$restHttpLib->call($testUrl);
$outcome = true;
$message = _('Connection Successful');
} catch (\Exception $e) {
$outcome = false;
$message = $e->getMessage();
}

return array(
'outcome' => $outcome,
'message' => $message
);
}
}
3 changes: 2 additions & 1 deletion www/api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@

/* Authenticate the user */
$log = new CentreonUserLog(0, $pearDB);
$auth = new CentreonAuth($_POST['username'], $_POST['password'], 0, $pearDB, $log, 1, "", "API");
$auth = new CentreonAuth($dependencyInjector, $_POST['username'], $_POST['password'], 0, $pearDB, $log, 1, "", "API");

if ($auth->passwdOk == 0) {
CentreonWebService::sendResult("Bad credentials", 403);
exit();
Expand Down
Loading

0 comments on commit 40cfedf

Please sign in to comment.