Test FPM FCGI envs without path info fix for custom source

This commit is contained in:
Jakub Zelenka 2023-03-12 19:20:13 +00:00
parent 3125155b5d
commit 92d2cd5cb8
No known key found for this signature in database
GPG Key ID: 1C0779DC5C0A9DE4
6 changed files with 338 additions and 0 deletions

View File

@ -0,0 +1,58 @@
--TEST--
FPM: FastCGI env var no path info fix for custom setup with PATH_INFO, PATH_TRANSLATED and path discard
--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] = no
php_admin_value[cgi.discard_path] = 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__,
],
uri: $scriptName . '/pinfo',
scriptFilename: $sourceFilePath,
scriptName: $scriptName,
)
->expectBody([$scriptName, $sourceFilePath, '/pinfo', '/pinfo']);
$tester->terminate();
$tester->close();
?>
Done
--EXPECT--
Done
--CLEAN--
<?php
require_once "tester.inc";
FPM\Tester::clean();
?>

View File

@ -0,0 +1,58 @@
--TEST--
FPM: FastCGI env var no path info fix for custom setup with PATH_INFO and PATH_TRANSLATED
--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] = no
php_admin_value[cgi.discard_path] = no
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' => $sourceFilePath,
],
uri: $scriptName . '/pinfo',
scriptFilename: $sourceFilePath . '/pinfo', // used just for variable display
scriptName: $scriptName,
)
->expectBody([$scriptName, $sourceFilePath . '/pinfo', '/pinfo', '/pinfo']);
$tester->terminate();
$tester->close();
?>
Done
--EXPECT--
Done
--CLEAN--
<?php
require_once "tester.inc";
FPM\Tester::clean();
?>

View File

@ -0,0 +1,56 @@
--TEST--
FPM: FastCGI env var no path info fix for custom setup with PATH_INFO and without PATH_TRANSLATED
--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] = no
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',
],
uri: $scriptName . '/pinfo',
scriptFilename: $sourceFilePath,
scriptName: $scriptName,
)
->expectBody([$scriptName, $sourceFilePath, '/pinfo', '/pinfo']);
$tester->terminate();
$tester->close();
?>
Done
--EXPECT--
Done
--CLEAN--
<?php
require_once "tester.inc";
FPM\Tester::clean();
?>

View File

@ -0,0 +1,56 @@
--TEST--
FPM: FastCGI env var no path info fix for custom setup without PATH_INFO and with PATH_TRANSLATED
--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] = no
php_admin_value[cgi.discard_path] = no
EOT;
$code = <<<EOT
<?php
echo \$_SERVER["SCRIPT_NAME"] . "\n";
echo \$_SERVER["SCRIPT_FILENAME"] . "\n";
echo \$_SERVER["PHP_SELF"];
EOT;
$tester = new FPM\Tester($cfg, $code);
[$sourceFilePath, $scriptName] = $tester->createSourceFileAndScriptName();
$tester->start();
$tester->expectLogStartNotices();
$tester
->request(
headers: [
'PATH_TRANSLATED' => $sourceFilePath,
],
uri: $scriptName . '/pinfo',
scriptFilename: $sourceFilePath . '/pinfo', // should be ignored as PATH_TRANSLATED is used
scriptName: $scriptName,
)
->expectBody([$scriptName, $sourceFilePath . '/pinfo', $scriptName]);
$tester->terminate();
$tester->close();
?>
Done
--EXPECT--
Done
--CLEAN--
<?php
require_once "tester.inc";
FPM\Tester::clean();
?>

View File

@ -0,0 +1,52 @@
--TEST--
FPM: FastCGI env var no path info fix for custom setup without PATH_INFO and PATH_TRANSLATED
--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] = no
EOT;
$code = <<<EOT
<?php
echo \$_SERVER["SCRIPT_NAME"] . "\n";
echo \$_SERVER["SCRIPT_FILENAME"] . "\n";
echo \$_SERVER["PHP_SELF"];
EOT;
$tester = new FPM\Tester($cfg, $code);
[$sourceFilePath, $scriptName] = $tester->createSourceFileAndScriptName();
$tester->start();
$tester->expectLogStartNotices();
$tester
->request(
uri: $scriptName . '/pinfo',
scriptFilename: $sourceFilePath,
scriptName: $scriptName,
)
->expectBody([$scriptName, $sourceFilePath, $scriptName]);
$tester->terminate();
$tester->close();
?>
Done
--EXPECT--
Done
--CLEAN--
<?php
require_once "tester.inc";
FPM\Tester::clean();
?>

View File

@ -0,0 +1,58 @@
--TEST--
FPM: FastCGI env var no path info fix for custom setup without SCRIPT_FILENAME and with PATH_TRANSLATED
--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] = no
php_admin_value[cgi.discard_path] = yes
EOT;
$code = <<<EOT
<?php
echo \$_SERVER["SCRIPT_NAME"] . "\n";
echo \$_SERVER["SCRIPT_FILENAME"] ?? 'unset' . "\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' => $sourceFilePath,
],
uri: $scriptName . '/pinfo',
scriptFilename: '',
scriptName: $scriptName,
)
->expectBody([$scriptName, 'unset', '/pinfo', '/pinfo']);
$tester->terminate();
$tester->close();
?>
Done
--EXPECT--
Done
--CLEAN--
<?php
require_once "tester.inc";
FPM\Tester::clean();
?>