Files
2026-06-30 19:53:28 +02:00

27 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
require_once PLUGIN_ROOT . '/exec/lib/Http.php';
test('http redirect page performs top level browser navigation', function (): void {
$html = Http::redirectPageHtml('https://mx1.domena.pl:2222/api/login/url?key=SECRET&x=1');
assert_contains('window.top.location.replace', $html);
assert_contains('window.location.replace', $html);
assert_contains('<meta http-equiv="refresh"', $html);
assert_contains('https://mx1.domena.pl:2222/api/login/url?key=SECRET&amp;x=1', $html);
assert_contains('https://mx1.domena.pl:2222/api/login/url?key=SECRET\\u0026x=1', $html);
});
test('http raw response is a complete http response for directadmin proxy', function (): void {
$response = Http::rawHttpResponse(200, [
'Content-Type' => 'text/html; charset=UTF-8',
'Cache-Control' => 'no-store, private',
], '<!doctype html><html></html>');
assert_contains("HTTP/1.1 200 OK\r\n", $response);
assert_contains("Content-Type: text/html; charset=UTF-8\r\n", $response);
assert_contains("Content-Length: 28\r\n", $response);
assert_contains("\r\n\r\n<!doctype html><html></html>", $response);
});