diff options
author | Andrei Belov <defan@nginx.com> | 2018-12-20 20:25:50 +0300 |
---|---|---|
committer | Andrei Belov <defan@nginx.com> | 2018-12-20 20:25:50 +0300 |
commit | 82e12d0cdeeb707ad4b1aef91c5e90b4347b0831 (patch) | |
tree | 19ef4cf3dea340fa365af022c76543f92d1e2e0a /test/test_php_application.py | |
parent | b140ac29e5571e9abaafce006932f15d86b78803 (diff) | |
parent | 4195a29fabfe65f5a28baf2405c2077e2ba3c09a (diff) | |
download | unit-82e12d0cdeeb707ad4b1aef91c5e90b4347b0831.tar.gz unit-82e12d0cdeeb707ad4b1aef91c5e90b4347b0831.tar.bz2 |
Merged with the default branch.
Diffstat (limited to '')
-rw-r--r-- | test/test_php_application.py | 112 |
1 files changed, 111 insertions, 1 deletions
diff --git a/test/test_php_application.py b/test/test_php_application.py index 0dbc743d..e0058d9a 100644 --- a/test/test_php_application.py +++ b/test/test_php_application.py @@ -1,11 +1,16 @@ import unittest import unit +import re class TestUnitPHPApplication(unit.TestUnitApplicationPHP): def setUpClass(): unit.TestUnit().check_modules('php') + def search_disabled(self, name): + p = re.compile(name + '\(\) has been disabled') + return self.search_in_log(p) + def test_php_application_variables(self): self.load('variables') @@ -204,5 +209,110 @@ class TestUnitPHPApplication(unit.TestUnitApplicationPHP): self.assertEqual(self.get()['headers']['X-Precision'], '5', 'ini value repeat') + def test_php_application_disable_functions_exec(self): + self.load('highlight_file_exec') + + self.conf({"admin": { "disable_functions": "exec" }}, + 'applications/highlight_file_exec/options') + + self.get() + + self.assertIsNotNone(self.search_disabled('exec'), + 'disable_functions exec') + self.assertIsNone(self.search_disabled('highlight_file'), + 'disable_functions highlight_file') + + def test_php_application_disable_functions_highlight_file(self): + self.load('highlight_file_exec') + + self.conf({"admin": { "disable_functions": "highlight_file" }}, + 'applications/highlight_file_exec/options') + + self.get() + + self.assertIsNone(self.search_disabled('exec'), + 'disable_functions exec') + self.assertIsNotNone(self.search_disabled('highlight_file'), + 'disable_functions highlight_file') + + def test_php_application_disable_functions_comma(self): + self.load('highlight_file_exec') + + self.conf({"admin": { "disable_functions": "exec,highlight_file" }}, + 'applications/highlight_file_exec/options') + + self.get() + + self.assertIsNotNone(self.search_disabled('exec'), + 'disable_functions exec') + self.assertIsNotNone(self.search_disabled('highlight_file'), + 'disable_functions highlight_file') + + def test_php_application_disable_functions_space(self): + self.load('highlight_file_exec') + + self.conf({"admin": { "disable_functions": "exec highlight_file" }}, + 'applications/highlight_file_exec/options') + + self.get() + + self.assertIsNotNone(self.search_disabled('exec'), + 'disable_functions exec') + self.assertIsNotNone(self.search_disabled('highlight_file'), + 'disable_functions highlight_file') + + def test_php_application_disable_functions_user(self): + self.load('highlight_file_exec') + + self.conf({"user": { "disable_functions": "exec" }}, + 'applications/highlight_file_exec/options') + + self.get() + + self.assertIsNotNone(self.search_disabled('exec'), + 'disable_functions exec') + self.assertIsNone(self.search_disabled('highlight_file'), + 'disable_functions highlight_file') + + def test_php_application_disable_functions_nonexistent(self): + self.load('highlight_file_exec') + + self.conf({"admin": { "disable_functions": "blah" }}, + 'applications/highlight_file_exec/options') + + self.get() + + self.assertIsNone(self.search_disabled('exec'), + 'disable_functions exec') + self.assertIsNone(self.search_disabled('highlight_file'), + 'disable_functions highlight_file') + + def test_php_application_disable_classes(self): + self.load('date_time') + + self.get() + + self.assertIsNone(self.search_disabled('DateTime'), + 'disable_classes before') + + self.conf({"admin": { "disable_classes": "DateTime" }}, + 'applications/date_time/options') + + self.get() + + self.assertIsNotNone(self.search_disabled('DateTime'), + 'disable_classes') + + def test_php_application_disable_classes_user(self): + self.load('date_time') + + self.conf({"user": { "disable_classes": "DateTime" }}, + 'applications/date_time/options') + + self.get() + + self.assertIsNotNone(self.search_disabled('DateTime'), + 'disable_classes user') + if __name__ == '__main__': - unittest.main() + TestUnitPHPApplication.main() |