summaryrefslogtreecommitdiffhomepage
path: root/test/test_php_targets.py (follow)
AgeCommit message (Collapse)AuthorFilesLines
2023-11-08Tests: 8XXX used as default port range.Andrei Zeliankou1-3/+3
After the launch of the project, the testing infrastructure was shared with nginx project in some cases. To avoid port overlap, a decision was made to shift the port range for Unit tests. This problem was resolved a long time ago and is no longer relevant, so it is now safe to use port 8XXX range as the default, as it is more appropriate for testing purposes.
2023-06-14Tests: get rid of classes in test files.Andrei Zeliankou1-86/+86
Class usage came from the unittest framework and it was always redundant after migration to the pytest. This commit removes classes from files containing tests to make them more readable and understandable.
2023-06-12Tests: prerequisites checking reworked.Andrei Zeliankou1-2/+2
Prerequisites check moved to the module level to simplify class structure. Discovery and prerequisites checks functions moved to the separate files. Introduced "require" fixture to provide per-test requirements check.
2023-02-21Tests: switched to using f-strings.Andrei Zeliankou1-5/+6
Previously, it was necessary to support older versions of Python for compatibility. F-strings were released in Python 3.6. Python 3.5 was marked as unsupported by the end of 2020, so now it's possible to start using f-strings safely for better readability and performance.
2023-01-30Tests: Add some PHP tests for 403 and 404 error handling.Andrew Clayton1-1/+1
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 <alx@nginx.com> Cc: Andrei Zeliankou <zelenkov@nginx.com> [ Incorporates a couple of small test cleanups from Andrei ] Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2023-01-12PHP: Fix a potential problem parsing the path.Andrew Clayton1-0/+1
@dward on GitHub reported an issue with a URL like http://foo.bar/test.php?blah=test.php/foo where we would end up trying to run the script test.php?blah=test.php In the PHP module the format 'file.php/' is treated as a special case in nxt_php_dynamic_request() where we check the _path_ part of the url for the string '.php/'. The problem is that the path actually also contains the query string, thus we were finding 'test.php/' in the above URL and treating that whole path as the script to run. The fix is simple, replace the strstr(3) with a memmem(3), where we can limit the amount of path we use for the check. The trick here and what is not obvious from the code is that while path.start points to the whole path including the query string, path.length only contains the length of the _path_ part. NOTE: memmem(3) is a GNU extension and is neither specified by POSIX or ISO C, however it is available on a number of other systems, including: FreeBSD, OpenBSD, NetBSD, illumos, and macOS. If it comes to it we can implement a simple alternative for systems which lack memmem(3). This also adds a test case (provided by @dward) to cover this. Closes: <https://github.com/nginx/unit/issues/781> Cc: Andrei Zeliankou <zelenkov@nginx.com> Reviewed-by: Alejandro Colomar <alx@nginx.com> Reviewed-by: Andrei Zeliankou <zelenkov@nginx.com> [test] Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2021-12-12Tests: fixed type of applications.Andrei Zeliankou1-2/+2
2020-12-06Tests: options moved to the separate class.Andrei Zeliankou1-1/+1
This change is necessary to separate the logic and prevent possible circular dependency.
2020-10-07Tests: minor fixes.Andrei Zeliankou1-1/+1
2020-09-16Tests: migrated to the pytest.Andrei Zeliankou1-111/+81
2020-07-28Tests: style.Andrei Zeliankou1-1/+0
2020-05-15Tests: added tests for "targets" option.Andrei Zeliankou1-0/+129