mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Test FPM FCGI envs with path info fix for Apache proxy balancer
This commit is contained in:
parent
92d2cd5cb8
commit
b53b0ac2ea
2 changed files with 115 additions and 0 deletions
57
sapi/fpm/tests/fcgi-env-pif-apache-balancer-legacy.phpt
Normal file
57
sapi/fpm/tests/fcgi-env-pif-apache-balancer-legacy.phpt
Normal file
|
@ -0,0 +1,57 @@
|
|||
--TEST--
|
||||
FPM: FastCGI env var path info fix for Apache balancer legacy setup
|
||||
--SKIPIF--
|
||||
<?php include "skipif.inc"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once "tester.inc";
|
||||
|
||||
$cfg = <<<EOT
|
||||
[global]
|
||||
error_log = {{FILE:LOG}}
|
||||
[unconfined]
|
||||
listen = {{ADDR}}
|
||||
pm = dynamic
|
||||
pm.max_children = 5
|
||||
pm.start_servers = 1
|
||||
pm.min_spare_servers = 1
|
||||
pm.max_spare_servers = 3
|
||||
php_admin_value[cgi.fix_pathinfo] = yes
|
||||
EOT;
|
||||
|
||||
$code = <<<EOT
|
||||
<?php
|
||||
echo \$_SERVER["SCRIPT_NAME"] . "\n";
|
||||
echo \$_SERVER["SCRIPT_FILENAME"] . "\n";
|
||||
echo \$_SERVER["PATH_INFO"] . "\n";
|
||||
echo \$_SERVER["PHP_SELF"];
|
||||
EOT;
|
||||
|
||||
$tester = new FPM\Tester($cfg, $code);
|
||||
[$sourceFilePath, $scriptName] = $tester->createSourceFileAndScriptName();
|
||||
$tester->start();
|
||||
$tester->expectLogStartNotices();
|
||||
$tester
|
||||
->request(
|
||||
headers: [
|
||||
'PATH_INFO' => '/pinfo',
|
||||
'PATH_TRANSLATED' => __DIR__ . '/pinfo',
|
||||
],
|
||||
uri: $scriptName . '/pinfo',
|
||||
scriptFilename: "proxy:balancer://" . $tester->getAddr() . $sourceFilePath,
|
||||
scriptName: $scriptName,
|
||||
)
|
||||
->expectBody([$scriptName, $sourceFilePath, '/pinfo', $scriptName . '/pinfo']);
|
||||
$tester->terminate();
|
||||
$tester->close();
|
||||
|
||||
?>
|
||||
Done
|
||||
--EXPECT--
|
||||
Done
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once "tester.inc";
|
||||
FPM\Tester::clean();
|
||||
?>
|
58
sapi/fpm/tests/fcgi-env-pif-apache-balancer-real.phpt
Normal file
58
sapi/fpm/tests/fcgi-env-pif-apache-balancer-real.phpt
Normal file
|
@ -0,0 +1,58 @@
|
|||
--TEST--
|
||||
FPM: FastCGI env var path info fix for Apache balancer real configuration
|
||||
--SKIPIF--
|
||||
<?php include "skipif.inc"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once "tester.inc";
|
||||
|
||||
$cfg = <<<EOT
|
||||
[global]
|
||||
error_log = {{FILE:LOG}}
|
||||
[unconfined]
|
||||
listen = {{ADDR}}
|
||||
pm = dynamic
|
||||
pm.max_children = 5
|
||||
pm.start_servers = 1
|
||||
pm.min_spare_servers = 1
|
||||
pm.max_spare_servers = 3
|
||||
php_admin_value[cgi.fix_pathinfo] = yes
|
||||
EOT;
|
||||
|
||||
$code = <<<EOT
|
||||
<?php
|
||||
echo \$_SERVER["SCRIPT_NAME"] . "\n";
|
||||
echo \$_SERVER["SCRIPT_FILENAME"] . "\n";
|
||||
echo \$_SERVER["PATH_INFO"] . "\n";
|
||||
echo \$_SERVER["PHP_SELF"];
|
||||
EOT;
|
||||
|
||||
$tester = new FPM\Tester($cfg, $code);
|
||||
[$sourceFilePath, $scriptName] = $tester->createSourceFileAndScriptName();
|
||||
$pathTranslatedPart = __DIR__ . $sourceFilePath . '/pinfo';
|
||||
$tester->start();
|
||||
$tester->expectLogStartNotices();
|
||||
$tester
|
||||
->request(
|
||||
headers: [
|
||||
'PATH_INFO' => $sourceFilePath . '/pinfo',
|
||||
'PATH_TRANSLATED' => 'proxy:balancer://myappcluster' . $pathTranslatedPart . $pathTranslatedPart,
|
||||
],
|
||||
uri: $scriptName . '/pinfo',
|
||||
scriptFilename: $sourceFilePath . '/pinfo',
|
||||
scriptName: '',
|
||||
)
|
||||
->expectBody([$sourceFilePath, $sourceFilePath, '/pinfo', $sourceFilePath . '/pinfo']);
|
||||
$tester->terminate();
|
||||
$tester->close();
|
||||
|
||||
?>
|
||||
Done
|
||||
--EXPECT--
|
||||
Done
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once "tester.inc";
|
||||
FPM\Tester::clean();
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue