summaryrefslogtreecommitdiffhomepage
path: root/test/test_php_application.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/test_php_application.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/test_php_application.py b/test/test_php_application.py
index f1dcc995..f442f551 100644
--- a/test/test_php_application.py
+++ b/test/test_php_application.py
@@ -4,6 +4,7 @@ import re
import shutil
import signal
import time
+from pathlib import Path
import pytest
from unit.applications.lang.php import TestApplicationPHP
@@ -620,6 +621,49 @@ opcache.preload_user = %(user)s
assert resp['status'] == 200, 'status'
assert resp['body'] != '', 'body not empty'
+ def test_php_application_trailing_slash(self, temp_dir):
+ new_root = temp_dir + "/php-root"
+ os.makedirs(new_root + '/path')
+
+ Path(new_root + '/path/index.php').write_text('<?php echo "OK\n"; ?>')
+
+ addr = temp_dir + '/sock'
+
+ assert 'success' in self.conf(
+ {
+ "listeners": {
+ "*:7080": {"pass": "applications/php-path"},
+ "unix:" + addr: {"pass": "applications/php-path"},
+ },
+ "applications": {
+ "php-path": {
+ "type": self.get_application_type(),
+ "processes": {"spare": 0},
+ "root": new_root,
+ }
+ },
+ }
+ ), 'configure trailing slash'
+
+ assert self.get(url='/path/')['status'] == 200, 'uri with trailing /'
+
+ resp = self.get(url='/path?q=a')
+ assert resp['status'] == 301, 'uri without trailing /'
+ assert (
+ resp['headers']['Location'] == 'http://localhost:7080/path/?q=a'
+ ), 'Location with query string'
+
+ resp = self.get(
+ sock_type='unix',
+ addr=addr,
+ url='/path',
+ headers={'Host': 'foo', 'Connection': 'close'},
+ )
+ assert resp['status'] == 301, 'uri without trailing /'
+ assert (
+ resp['headers']['Location'] == 'http://foo/path/'
+ ), 'Location with custom Host over UDS'
+
def test_php_application_extension_check(self, temp_dir):
self.load('phpinfo')