Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
Fix acceptance test (#6440)
Browse files Browse the repository at this point in the history
* fix(newman):Add parameter for contentTYpe

* fix(clapi): Remove parent relation

* refactor(kb) clean kb database access

* fix(KB) use last mediawiki version
  • Loading branch information
loiclau authored Jul 5, 2018
1 parent 016a2b6 commit ac72530
Show file tree
Hide file tree
Showing 20 changed files with 207 additions and 561 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The prerequisites are the same as for Centreon Web in its 2.8.x version.
Mediawiki
*********

**Centreon Knowledge Base** requires **MediaWiki** to be installed (version = 1.21) on your system
**Centreon Knowledge Base** requires **MediaWiki** to be installed (version = 1.31) on your system
. Mediawiki is provided with RPM packages on Centreon repository.

You can `download MediaWiki here <http://www.mediawiki.org/wiki/MediaWiki>`_ and access the `documentation here <http://www.mediawiki.org/wiki/User_hub>`_.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Le module dispose donc des même pré-requis.
Mediawiki
*********

**Centreon Knowledge Base** requiert que **MediaWiki** (version = 1.21) soit installé sur un serveur.
**Centreon Knowledge Base** requiert que **MediaWiki** (version = 1.31) soit installé sur un serveur.
Un paquet RPM de Mediawiki est disponible sur les dépôts Centreon.

Alternativement vous pouvez `télécharger MediaWiki ici <http://www.mediawiki.org/wiki/MediaWiki>`_
Expand Down
12 changes: 6 additions & 6 deletions tests/rest_api/rest_api.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@
"var contentType = postman.getResponseHeader(\"Content-Type\");",
"",
"tests[\"Content-Type is present\"] = contentType !== null;",
"tests[\"Content-Type is application/json\"] = contentType === \"application/json\";",
"tests[\"Content-Type is application/json\"] = contentType === \"application/json;charset=utf-8\";",
"",
"var jsonData = JSON.parse(responseBody);",
"var hostData = jsonData.result;",
Expand Down Expand Up @@ -45929,7 +45929,7 @@
"tests[\"Status code is 200\"] = responseCode.code === 200;",
"",
"var contentType = postman.getResponseHeader(\"Content-Type\");",
"tests[\"Content-Type is application/json\"] = contentType === \"application/json\";",
"tests[\"Content-Type is application/json\"] = contentType === \"application/json;charset=utf-8\";",
"",
"var jsonData = JSON.parse(responseBody);",
"var result= jsonData.result;",
Expand Down Expand Up @@ -46032,7 +46032,7 @@
"tests[\"Status code is 200\"] = responseCode.code === 200;",
"",
"var contentType = postman.getResponseHeader(\"Content-Type\");",
"tests[\"Content-Type is application/json\"] = contentType === \"application/json\";",
"tests[\"Content-Type is application/json\"] = contentType === \"application/json;charset=utf-8\";",
"",
"var jsonData = JSON.parse(responseBody);",
"var result= jsonData.result;",
Expand Down Expand Up @@ -46139,7 +46139,7 @@
"tests[\"Status code is 200\"] = responseCode.code === 200;",
"",
"var contentType = postman.getResponseHeader(\"Content-Type\");",
"tests[\"Content-Type is application/json\"] = contentType === \"application/json\";",
"tests[\"Content-Type is application/json\"] = contentType === \"application/json;charset=utf-8\";",
"",
"var jsonData = JSON.parse(responseBody);",
"var result= jsonData.result;",
Expand Down Expand Up @@ -46243,7 +46243,7 @@
"tests[\"Status code is 200\"] = responseCode.code === 200;",
"",
"var contentType = postman.getResponseHeader(\"Content-Type\");",
"tests[\"Content-Type is application/json\"] = contentType === \"application/json\";",
"tests[\"Content-Type is application/json\"] = contentType === \"application/json;charset=utf-8\";",
"",
"var jsonData = JSON.parse(responseBody);",
"var result= jsonData.result;",
Expand Down Expand Up @@ -46350,7 +46350,7 @@
"tests[\"Status code is 200\"] = responseCode.code === 200;",
"",
"var contentType = postman.getResponseHeader(\"Content-Type\");",
"tests[\"Content-Type is application/json\"] = contentType === \"application/json\";",
"tests[\"Content-Type is application/json\"] = contentType === \"application/json;charset=utf-8\";",
"",
"var jsonData = JSON.parse(responseBody);",
"var result= jsonData.result;",
Expand Down
2 changes: 0 additions & 2 deletions www/class/centreon-clapi/centreonSeverityAbstract.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ public function unsetseverity($parameters)
'level' => null,
'icon_id' => null
);
$updateParams['objectId'] = $objectId;
parent::setparam($updateParams);

$this->object->update($objectId, $updateParams);
$this->addAuditLog(
Expand Down
107 changes: 10 additions & 97 deletions www/class/centreon-knowledge/procedures.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

define("PROCEDURE_SIMPLE_MODE", 0);
define("PROCEDURE_INHERITANCE_MODE", 1);
require_once _CENTREON_PATH_ . "/www/class/centreon-knowledge/wikiApi.class.php";

class procedures
{
Expand All @@ -48,6 +49,7 @@ class procedures
public $serviceTplList;
public $hostIconeList;
public $diff;
public $api;

/**
* Constructor
Expand All @@ -60,15 +62,14 @@ class procedures
* @param CentreonDB $pearDB
* @param string $db_prefix
*/
public function __construct($retry, $db_name, $db_user, $db_host, $db_password, $pearDB, $db_prefix)
public function __construct($pearDB)
{
$this->DB = new procedures_DB_Connector($retry, $db_name, $db_user, $db_host, $db_password);
$this->api = new WikiApi();
$this->centreon_DB = $pearDB;
$this->hostList = array();
$this->hosttplList = array();
$this->serviceList = array();
$this->serviceTplList = array();
$this->db_prefix = $db_prefix;
$this->setProcedures();
}

Expand All @@ -79,11 +80,12 @@ public function __construct($retry, $db_name, $db_user, $db_host, $db_password,
*/
private function setProcedures()
{
$DBRESULT = $this->DB->query("SELECT page_title, page_id FROM " . $this->db_prefix . "page");
while ($page = $DBRESULT->fetch()) {
$this->procList[$page["page_title"]] = $page["page_id"];
$pages = $this->api->getAllPages();
//replace space
foreach ($pages as $page){
$page = str_replace(' ', '_', $page);
$this->procList[$page] = '';
}
$DBRESULT->closeCursor();
}

/**
Expand Down Expand Up @@ -298,96 +300,6 @@ public function setServiceInformations()
unset($data);
}

/**
* Duplicate
*
* @param string $template
* @param string $object
* @param int $type
* @return void
*/
public function duplicate($template, $object, $type)
{
$debug = 0;

if (isset($template)) {
/*
* Get Template
*/
if ($type == 2) {
$template = "H-TPL-" . $template;
}
if ($type == 3) {
$template = "S-TPL-" . $template;
}
$DBRESULT = $this->DB->query(
"SELECT * FROM " . $this->db_prefix . "page WHERE page_title LIKE '$template'"
);
$data = $DBRESULT->fetchRow();
$DBRESULT->closeCursor();

if ($debug) {
print "SELECT * FROM " . $this->db_prefix . "revision WHERE rev_page LIKE '" .
$data['page_id'] . "' ORDER BY rev_text_id DESC LIMIT 1";
}
$DBRESULT = $this->DB->query(
"SELECT * FROM " . $this->db_prefix . "revision WHERE " . $this->db_prefix .
"rev_page LIKE '" . $data['page_id'] . "' ORDER BY rev_text_id DESC LIMIT 1"
);
$revision = $DBRESULT->fetchRow();
$DBRESULT->closeCursor();

if ($debug) {
print "SELECT * FROM " . $this->db_prefix . "text WHERE old_id = '" .
$data['page_id'] . "' ORDER BY old_id DESC LIMIT 1";
}
$DBRESULT = $this->DB->query(
"SELECT * FROM " . $this->db_prefix . "text WHERE old_id = '" .
$data['page_id'] . "' ORDER BY old_id DESC LIMIT 1"
);
$text = $DBRESULT->fetchRow();
$DBRESULT->closeCursor();

switch ($type) {
case 0:
$object = "Host_:_" . $object;
break;
case 1:
$object = "Service_:_" . $object;
break;
case 2:
$object = "Host-Template_:_" . $object;
break;
case 3:
$object = "Service-Template_:_" . $object;
break;
}

$dateTouch = date("YmdHis");
$this->DB->query(
"INSERT INTO " . $this->db_prefix . "page (`page_namespace` ,`page_title`,`page_counter`, " .
" `page_is_redirect`,`page_is_new`,`page_random` ,`page_touched`,`page_latest`,`page_len`) " .
" VALUES ('0', '" . $object . "', '0', '0', '1', '" . $data["page_random"] . "', '" .
$dateTouch . "', '" . $data["page_latest"] . "', '" . $data["page_len"] . "')"
);
$DBRESULT = $this->DB->query("SELECT MAX(page_id) FROM " . $this->db_prefix . "page");
$id = $DBRESULT->fetchRow();

$this->DB->query(
"INSERT INTO `text` (old_id, old_text, old_flags) VALUE (NULL, '" .
$text["old_text"] . "', '" . $text["old_flags"] . "')"
);
$this->DB->query(
"INSERT INTO `revision` (rev_page, rev_text_id, rev_comment, rev_user_text, rev_timestamp, " .
" rev_len) VALUE ('" . $id["MAX(page_id)"] . "', (SELECT MAX(old_id) FROM text), '" .
$revision["rev_comment"] . "', '" . $revision["rev_user_text"] . "','" . $dateTouch .
"','" . $revision["rev_len"] . "')"
);
} else {
;
}
}

/**
* Check if Service has procedure
*
Expand Down Expand Up @@ -427,6 +339,7 @@ public function hostHasProcedure($key, $templates = array(), $mode = PROCEDURE_S
if (isset($this->procList["Host_:_" . $key])) {
return true;
}

if ($mode == PROCEDURE_SIMPLE_MODE) {
return false;
} elseif ($mode == PROCEDURE_INHERITANCE_MODE) {
Expand Down
139 changes: 0 additions & 139 deletions www/class/centreon-knowledge/procedures_DB_Connector.class.php

This file was deleted.

Loading

0 comments on commit ac72530

Please sign in to comment.