fix: parse directadmin cli post data
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once PLUGIN_ROOT . '/exec/lib/CsrfGuard.php';
|
||||
require_once PLUGIN_ROOT . '/exec/lib/Http.php';
|
||||
require_once PLUGIN_ROOT . '/exec/lib/Settings.php';
|
||||
require_once PLUGIN_ROOT . '/exec/lib/Lang.php';
|
||||
require_once PLUGIN_ROOT . '/exec/lib/DirectAdminUser.php';
|
||||
@@ -37,3 +38,31 @@ test('csrf form fields use plugin scoped names to avoid directadmin token collis
|
||||
assert_contains('name="gar_csrf_token"', $html);
|
||||
assert_false(str_contains($html, 'name="csrf_token"'));
|
||||
});
|
||||
|
||||
test('http bootstrap populates post data from directadmin cli environment', function (): void {
|
||||
$oldGet = $_GET;
|
||||
$oldPost = $_POST;
|
||||
$oldRequest = $_REQUEST;
|
||||
$oldServer = $_SERVER;
|
||||
|
||||
putenv('REQUEST_METHOD=POST');
|
||||
putenv('QUERY_STRING=id=abc');
|
||||
putenv('POST=gar_csrf_ts=123&gar_csrf_sid=sid&gar_csrf_token=token&body=Hello+World');
|
||||
|
||||
try {
|
||||
Http::bootstrapGlobals();
|
||||
assert_same('POST', Http::method());
|
||||
assert_same('abc', Http::getString($_GET, 'id'));
|
||||
assert_same('123', Http::getString($_POST, 'gar_csrf_ts'));
|
||||
assert_same('token', Http::getString($_POST, 'gar_csrf_token'));
|
||||
assert_same('Hello World', Http::getString($_POST, 'body'));
|
||||
} finally {
|
||||
putenv('REQUEST_METHOD');
|
||||
putenv('QUERY_STRING');
|
||||
putenv('POST');
|
||||
$_GET = $oldGet;
|
||||
$_POST = $oldPost;
|
||||
$_REQUEST = $oldRequest;
|
||||
$_SERVER = $oldServer;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user