Skip to content

Commit 8cb7e0b

Browse files
committed
Tests: Add some PHP tests for 403 and 404 error handling.
Since the previous commit, we now properly handle 403 Forbidden & 404 Not Found errors in the PHP language module. This adds a test for 403 Forbidden to test/test_php_application.py, but also fixes a test in test/test_php_targets.py where we were checking for 503 but should have been a 404, which we now do. Acked-by: Alejandro Colomar <[email protected]> Cc: Andrei Zeliankou <[email protected]> [ Incorporates a couple of small test cleanups from Andrei ] Signed-off-by: Andrew Clayton <[email protected]>
1 parent 5f186d5 commit 8cb7e0b

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Diff for: test/test_php_application.py

+20
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,26 @@ def test_php_application_trailing_slash(self, temp_dir):
664664
resp['headers']['Location'] == 'http://foo/path/'
665665
), 'Location with custom Host over UDS'
666666

667+
def test_php_application_forbidden(self, temp_dir):
668+
new_root = temp_dir + "/php-root"
669+
os.makedirs(new_root + '/path')
670+
os.chmod(new_root + '/path', 0o000)
671+
672+
assert 'success' in self.conf(
673+
{
674+
"listeners": {"*:7080": {"pass": "applications/php-path"}},
675+
"applications": {
676+
"php-path": {
677+
"type": self.get_application_type(),
678+
"processes": {"spare": 0},
679+
"root": new_root,
680+
}
681+
},
682+
}
683+
), 'forbidden directory'
684+
685+
assert self.get(url='/path/')['status'] == 403, 'access forbidden'
686+
667687
def test_php_application_extension_check(self, temp_dir):
668688
self.load('phpinfo')
669689

Diff for: test/test_php_targets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_php_application_targets(self):
4545

4646
assert self.get(url='/1')['body'] == '1'
4747
assert self.get(url='/2')['body'] == '2'
48-
assert self.get(url='/blah')['status'] == 503 # TODO 404
48+
assert self.get(url='/blah')['status'] == 404
4949
assert self.get(url='/')['body'] == 'index'
5050
assert self.get(url='/1.php?test=test.php/')['body'] == '1'
5151

0 commit comments

Comments
 (0)