mirror of
https://github.com/Cacti/cacti.git
synced 2026-10-24 03:57:32 +09:00
* fix(plugins): honor version range boundaries and compatibility status Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix(plugins): preserve null hook diagnostics and enforce dependency versions Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix(plugins): report config failures and confine error attribution Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix(plugins): guard entrypoint frames and bind realm filenames Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix(plugins): propagate install hook failures on develop Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix(plugins): match realm filenames literally Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * docs(changelog): defer release entries to final backlog PR Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * test(plugins): add standard GPL headers Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * ci(coverage): require 80 percent of changed PHP statements Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * ci: share changed-code coverage contracts and enforce shell policy Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix(ci): run request coverage with portable path matching Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * ci: retain bootstrap coverage and validate request dispatch Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * test: synchronize native coverage fixture dispatch Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * test: measure coverage at the exact PR revision Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> --------- Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
57 lines
2.5 KiB
PHP
57 lines
2.5 KiB
PHP
<?php
|
|
/*
|
|
+-------------------------------------------------------------------------+
|
|
| Copyright (C) 2004-2026 The Cacti Group |
|
|
| |
|
|
| This program is free software; you can redistribute it and/or |
|
|
| modify it under the terms of the GNU General Public License |
|
|
| as published by the Free Software Foundation; either version 2 |
|
|
| of the License, or (at your option) any later version. |
|
|
| |
|
|
| This program is distributed in the hope that it will be useful, |
|
|
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
| GNU General Public License for more details. |
|
|
+-------------------------------------------------------------------------+
|
|
| Cacti: The Complete RRDtool-based Graphing Solution |
|
|
+-------------------------------------------------------------------------+
|
|
*/
|
|
|
|
require_once dirname(__DIR__, 2) . '/Helpers/CactiStubs.php';
|
|
require_once dirname(__DIR__, 3) . '/include/global.php';
|
|
|
|
test('plugin configuration hook preserves the legacy null diagnostic response (#7968)', function ($body, $expected) {
|
|
$name = 'config_fixture_' . bin2hex(random_bytes(6));
|
|
$directory = CACTI_PATH_PLUGINS . '/' . $name;
|
|
mkdir($directory);
|
|
$saved_session = $_SESSION;
|
|
unset($_SESSION[SESS_MESSAGES]['plugin_config']);
|
|
|
|
try {
|
|
file_put_contents($directory . '/setup.php', '<?php ' . ($body === null ? '' : 'function plugin_' . $name . '_check_config() {' . $body . '}'));
|
|
expect(api_plugin_check_config($name))->toBe($expected);
|
|
|
|
if ($expected !== true) {
|
|
$message = $_SESSION[SESS_MESSAGES]['plugin_config'];
|
|
expect($message['message'])->toContain($name);
|
|
expect($message['level'])->toBe($expected === null ? MESSAGE_LEVEL_WARN : MESSAGE_LEVEL_ERROR);
|
|
} else {
|
|
expect(isset($_SESSION[SESS_MESSAGES]['plugin_config']))->toBeFalse();
|
|
}
|
|
} finally {
|
|
$_SESSION = $saved_session;
|
|
unlink($directory . '/setup.php');
|
|
rmdir($directory);
|
|
}
|
|
})->with([
|
|
['return true;', true],
|
|
['return false;', false],
|
|
['return null;', null],
|
|
['', null],
|
|
[null, true],
|
|
]);
|
|
|
|
test('missing plugin setup does not pass the configuration check', function () {
|
|
expect(api_plugin_check_config('missing_config_' . bin2hex(random_bytes(6))))->toBeFalse();
|
|
});
|