summaryrefslogtreecommitdiffhomepage
path: root/test/test_php_application.py
diff options
context:
space:
mode:
authorAndrei Belov <defan@nginx.com>2019-08-22 21:33:54 +0300
committerAndrei Belov <defan@nginx.com>2019-08-22 21:33:54 +0300
commita07c4d30a64f781f93730576b5dced32422a9935 (patch)
tree06ebfaa66845a057b8069014c5379b2dcfc80861 /test/test_php_application.py
parent8a579acddeae0c0106e15d82aa7220ac01deba84 (diff)
parentc47af243b0e805376c4ec908f21e07dc811b33f0 (diff)
downloadunit-a07c4d30a64f781f93730576b5dced32422a9935.tar.gz
unit-a07c4d30a64f781f93730576b5dced32422a9935.tar.bz2
Merged with the default branch.1.10.0-1
Diffstat (limited to '')
-rw-r--r--test/test_php_application.py83
1 files changed, 82 insertions, 1 deletions
diff --git a/test/test_php_application.py b/test/test_php_application.py
index 8032e96e..ee2048b5 100644
--- a/test/test_php_application.py
+++ b/test/test_php_application.py
@@ -24,6 +24,7 @@ class TestPHPApplication(TestApplicationPHP):
'Connection': 'close',
},
body=body,
+ url='/index.php/blah?var=val'
)
self.assertEqual(resp['status'], 200, 'status')
@@ -54,7 +55,8 @@ class TestPHPApplication(TestApplicationPHP):
'Connection': 'close',
'Content-Length': str(len(body)),
'Request-Method': 'POST',
- 'Request-Uri': '/',
+ 'Path-Info': '/blah',
+ 'Request-Uri': '/index.php/blah?var=val',
'Http-Host': 'localhost',
'Server-Protocol': 'HTTP/1.1',
'Custom-Header': 'blah',
@@ -102,6 +104,46 @@ class TestPHPApplication(TestApplicationPHP):
self.assertEqual(resp['status'], 200, 'status')
self.assertNotEqual(resp['body'], '', 'body not empty')
+ def test_php_application_header_status(self):
+ self.load('header')
+
+ self.assertEqual(
+ self.get(
+ headers={
+ 'Host': 'localhost',
+ 'Connection': 'close',
+ 'X-Header': 'HTTP/1.1 404 Not Found',
+ }
+ )['status'],
+ 404,
+ 'status',
+ )
+
+ self.assertEqual(
+ self.get(
+ headers={
+ 'Host': 'localhost',
+ 'Connection': 'close',
+ 'X-Header': 'http/1.1 404 Not Found',
+ }
+ )['status'],
+ 404,
+ 'status case insensitive',
+ )
+
+ self.assertEqual(
+ self.get(
+ headers={
+ 'Host': 'localhost',
+ 'Connection': 'close',
+ 'X-Header': 'HTTP/ 404 Not Found',
+ }
+ )['status'],
+ 404,
+ 'status version empty',
+ )
+
+
def test_php_application_404(self):
self.load('404')
@@ -420,6 +462,45 @@ class TestPHPApplication(TestApplicationPHP):
self.get()['body'], r'012345', 'disable_classes before'
)
+ def test_php_application_script(self):
+ self.assertIn(
+ 'success', self.conf(
+ {
+ "listeners": {"*:7080": {"pass": "applications/script"}},
+ "applications": {
+ "script": {
+ "type": "php",
+ "processes": {"spare": 0},
+ "root": self.current_dir + "/php/script",
+ "script": "phpinfo.php",
+ }
+ },
+ }
+ ), 'configure script'
+ )
+
+ resp = self.get()
+
+ self.assertEqual(resp['status'], 200, 'status')
+ self.assertNotEqual(resp['body'], '', 'body not empty')
+
+ def test_php_application_index_default(self):
+ self.assertIn(
+ 'success', self.conf(
+ {
+ "listeners": {"*:7080": {"pass": "applications/phpinfo"}},
+ "applications": {
+ "phpinfo": {
+ "type": "php",
+ "processes": {"spare": 0},
+ "root": self.current_dir + "/php/phpinfo",
+ }
+ },
+ }
+ ), 'configure index default'
+ )
+
+ self.assertEqual(self.get()['status'], 200, 'status')
if __name__ == '__main__':
TestPHPApplication.main()