Files
cacti/tests/Unit/Installer/InstallerCommandFailureTest.php
Thomas Vincent 06c32ab13f fix(installer): preserve upgrade state and propagate failures (#8266)
* fix(installer): preserve upgrade state and propagate failures

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* docs(changelog): record installer recovery fixes for #8266

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* test(security): refresh installer sink inventories

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix(installer): retain merge precedence for browser parameters

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix(installer): defer debug settings until the process lock is held

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix(installer): enforce table conversion failures and postconditions

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* test(installer): refresh SQL audit baseline after clause refactor

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

---------

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
2026-10-11 17:08:12 -04:00

36 lines
1.5 KiB
PHP

<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2026 The Cacti Group |
+-------------------------------------------------------------------------+
*/
require_once CACTI_PATH_INSTALL . '/functions.php';
require_once CACTI_PATH_LIBRARY . '/installer.php';
test('installer commands preserve failed exit status and both output streams', function () {
$installer = (new ReflectionClass(Installer::class))->newInstanceWithoutConstructor();
$result = (new ReflectionMethod(Installer::class, 'runCommand'))->invoke($installer, [
PHP_BINARY,
'-r',
'fwrite(STDOUT, $argv[1] . PHP_EOL); fwrite(STDERR, "download failed\n"); exit(7);',
'literal argument; $(echo unexpected)',
]);
expect($result['exitCode'])->toBe(7)
->and($result['output'])->toContain('literal argument; $(echo unexpected)', 'download failed');
});
test('installer rejects unsupported request methods before loading application state', function () {
$installer = (new ReflectionClass(Installer::class))->newInstanceWithoutConstructor();
$result = (new ReflectionMethod(Installer::class, 'runCommand'))->invoke($installer, [
PHP_BINARY,
'-r',
'$_SERVER["REQUEST_METHOD"] = "GET"; register_shutdown_function(function () { echo " status=" . http_response_code(); }); require $argv[1];',
CACTI_PATH_INSTALL . '/step_json.php',
]);
expect($result['exitCode'])->toBe(0)
->and(implode(PHP_EOL, $result['output']))->toContain('Method not allowed', 'status=405');
});