summaryrefslogtreecommitdiffhomepage
path: root/test (follow)
AgeCommit message (Collapse)AuthorFilesLines
2024-02-21Tests: renamed test_python_procman.py since it's not Python-specificAndrei Zeliankou1-0/+0
Python applications are used only to generate responses here and can be replaced by applications written in any other language. While the "_python" prefix is used to indicate that the file contains tests specific to the Python module.
2024-02-21Tests: skip some of TLS reconfiguration tests under AddressSanitizerAndrei Zeliankou1-0/+7
These tests cause router crash when run with AddressSanitizer: ================================================================= ==77196==ERROR: AddressSanitizer: heap-use-after-free on address 0x60c000079340 at pc 0x55d56b132d4b bp 0x7f8cc7f346b0 sp 0x7f8cc7f346a0 READ of size 1 at 0x60c000079340 thread T1 #0 0x55d56b132d4a in nxt_openssl_conn_io_shutdown src/nxt_openssl.c:1466 #1 0x55d56b0f6a25 in nxt_h1p_closing src/nxt_h1proto.c:2069 #2 0x55d56b1009a6 in nxt_h1p_shutdown src/nxt_h1proto.c:2038 #3 0x55d56b1014c3 in nxt_h1p_request_close src/nxt_h1proto.c:1718 #4 0x55d56b1045c0 in nxt_http_request_close_handler src/nxt_http_request.c:864 #5 0x55d56b104988 in nxt_http_request_done src/nxt_http_request.c:795 #6 0x55d56b0ba0c3 in nxt_event_engine_start src/nxt_event_engine.c:542 #7 0x55d56b0dcac2 in nxt_router_thread_start src/nxt_router.c:3645 #8 0x55d56b0b421b in nxt_thread_trampoline src/nxt_thread.c:126 #9 0x7f8ccab95ac2 (/lib/x86_64-linux-gnu/libc.so.6+0x94ac2) #10 0x7f8ccac2784f (/lib/x86_64-linux-gnu/libc.so.6+0x12684f)
2024-02-21Tests: check for the AddressSanitizer flag during discoveryAndrei Zeliankou2-0/+3
This flag is necessary to either run or skip certain tests that have specific behavior depending on whether AddressSanitizer is enabled. For instance, some tests may fail only when the binary is compiled with AddressSanitizer.
2024-02-21Tests: Ruby hook tests unstable for version older 3.0Andrei Zeliankou1-1/+4
It can fail with reporting following alert: [alert] 137462#137462 mount("none", "/tmp/unit-test-636e0uh8/proc", "proc", 2097162, "") (16: Device or resource busy)
2024-02-21Python: bytearray body support for ASGI module.Andrei Zeliankou2-0/+28
@filiphanes requested support for bytearray and memoryview in the request body here: <https://github.com/nginx/unit/issues/648> This patch implements bytearray body support only. Memoryview body still need to be implemented.
2024-02-20Tests: NJS request variablesAndrei Zeliankou1-1/+35
2024-02-14fix: Take options as well as requestListener (#1091)Gabor Javorszky2-0/+10
* Take options as well as requestListener Unit-http have not kept up with the signature of nodejs's http package development. Nodejs allows an optional `options` object to be passed to the `createServer` function, we didn't. This resulted in function signature errors when user code that did make use of the options arg tried to call unit's replaced function. This change changes the signature to be more in line with how nodejs does it discarding it and printing a message to stdout. * Add test file to start node application with options * Add changes to docs/changes.xml Closes: https://github.com/nginx/unit/issues/1043
2024-01-29Tests: "if" option in access logging.Andrei Zeliankou1-0/+62
Conditional access logging was introduced here: https://github.com/nginx/unit/commit/4c91bebb50d06b28e369d68b23022caa072cf62d
2024-01-26Node.js: fixed "httpVersion" variable formatAndrei Zeliankou1-1/+1
According to the Node.js documenation this variable should only include numbering scheme. Thanks to @dbit-xia. Closes: https://github.com/nginx/unit/issues/1085
2024-01-16Tests: added Ruby tests with array in header valuesAndrei Zeliankou4-0/+41
2024-01-15Tests: pathlib used where appropriateAndrei Zeliankou72-256/+306
Also fixed various pylint errors and style issues.
2023-11-29Update third-party components for the Java module.Sergey A. Osokin1-1/+1
2023-11-17Tests: added more expected Ruby features.Andrei Zeliankou3-0/+27
2023-11-17Tests: Ruby input.rewind is no longer required.Andrei Zeliankou2-17/+0
For more information see: https://github.com/rack/rack/commit/42aff22f708123839ba706cbe659d108b47c40c7
2023-11-17Node.js: ServerResponse.flushHeaders() implemented.Andrei Zeliankou2-0/+11
This closes #1006 issue on GitHub. Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
2023-11-08Tests: 8XXX used as default port range.Andrei Zeliankou101-412/+412
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-11-08Var: $request_id variable.Andrei Zeliankou1-0/+20
This variable contains a string that is formed using random data and can be used as a unique request identifier. This closes #714 issue on GitHub.
2023-10-17Update third-party components for the Java module.Sergey A. Osokin1-1/+1
2023-10-11Tests: added PHP test with rewrite and query string.Andrei Zeliankou1-0/+30
This test reproduces https://github.com/nginx/unit/issues/964.
2023-10-10Update third-party components for the Java module.Sergey A. Osokin1-1/+1
2023-10-06Update third-party components for the Java module.Sergey A. Osokin1-1/+1
2023-10-02Tests: added Java test with multiple headers.Andrei Zeliankou1-0/+17
This test reproduce https://github.com/nginx/unit/issues/923.
2023-09-26Node.js: response body chunk can now be a Uint8Array.Andrei Zeliankou3-1/+9
Starting from Node.js 15.0.0 the chunk parameter of the response.write() can be a Uint8Array. This closes #870 issue on GitHub.
2023-09-04Tests: added tests for the "response_headers" option.Andrei Zeliankou1-0/+173
2023-07-11Tests: added tests for response header variables.Andrei Zeliankou2-0/+111
2023-07-10Tests: check TLS methods availability more carefully.Andrei Zeliankou2-0/+12
2023-07-10Tests: fixed exception handling.Andrei Zeliankou1-1/+3
2023-07-07Update third-party components for Unit's Java module.Sergey A. Osokin1-1/+1
2023-06-14Tests: no caching for $uri variable.Andrei Zeliankou1-0/+23
2023-06-14Tests: get rid of classes in test files.Andrei Zeliankou84-16006/+16647
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: removed alert skip, unnecessary after 1a48ea61fec8.Andrei Zeliankou3-12/+0
2023-06-12Tests: prerequisites checking reworked.Andrei Zeliankou79-548/+524
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-05-29Tests: more fixtures.Andrei Zeliankou24-341/+340
Common methods from applications/proto.py converted to the fixtures. sysctl check moved to the specific file where it is using. Some options moved to the constructor to have early access.
2023-05-29Tests: Log reworked.Andrei Zeliankou3-80/+90
All log-related code moved to the log.py.
2023-05-25Tests: assertion related fixes.Andrei Zeliankou11-95/+90
2023-05-25Tests: "temp_dir" fixture used were possible.Andrei Zeliankou3-5/+5
2023-05-25Tests: unified setup method usage.Andrei Zeliankou15-93/+113
To make fixtures accessible inside of setup methods in tests all these methods are renamed to the "setup_method_fixture" and decorated by autouse flag. Also all setup methods moved to the top of the files.
2023-05-25Tests: removed unused variables.Andrei Zeliankou34-91/+87
2023-05-19Tests: added tests for "server_version" option.Andrei Zeliankou1-0/+15
2023-05-19Tests: added ASGI application with IPv6 address test.Andrei Zeliankou1-0/+9
2023-05-10Tests: added tests for NJS loadable modules.Andrei Zeliankou6-15/+133
2023-05-09Tests: added tests for the URI rewrite.Andrei Zeliankou1-0/+219
2023-04-12HTTP: optimizing $request_line.Alejandro Colomar1-4/+4
Don't reconstruct a new string for the $request_line from the parsed method, target, and HTTP version, but rather keep a pointer to the original memory where the request line was received. This will be necessary for implementing URI rewrites, since we want to log the original request line, and not one constructed from the rewritten target. This implementation changes behavior (only for invalid requests) in the following way: Previous behavior was to log as many tokens from the request line as were parsed validly, thus: Request -> access log ; error log "GET / HTTP/1.1" -> "GET / HTTP/1.1" OK ; = "GET / HTTP/1.1" -> "GET / HTTP/1.1" [1] ; = "GET / HTTP/2.1" -> "GET / HTTP/2.1" OK ; = "GET / HTTP/1." -> "GET / HTTP/1." [2] ; "GET / HTTP/1. [null]" "GET / food" -> "GET / food" [2] ; "GET / food [null]" "GET / / HTTP/1.1" -> "GET / / HTTP/1.1" [2] ; = "GET / / HTTP/1.1" -> "GET / / HTTP/1.1" [2] ; = "GET food HTTP/1.1" -> "GET" ; "GET [null] [null]" "OPTIONS * HTTP/1.1" -> "OPTIONS" [3] ; "OPTIONS [null] [null]" "FOOBAR baz HTTP/1.1"-> "FOOBAR" ; "FOOBAR [null] [null]" "FOOBAR / HTTP/1.1" -> "FOOBAR / HTTP/1.1" ; = "get / HTTP/1.1" -> "-" ; " [null] [null]" "" -> "-" ; " [null] [null]" This behavior was rather inconsistent. We have several options to go forward with this patch: - NGINX behavior. Log the entire request line, up to '\r' | '\n', even if it was invalid. This is the most informative alternative. However, RFC-complying requests will probably not send invalid requests. This information would be interesting to users where debugging requests constructed manually via netcat(1) or a similar tool, or maybe for debugging a client, are important. It might be interesting to support this in the future if our users are interested; for now, since this approach requires looping over invalid requests twice, that's an overhead that we better avoid. - Previous Unit behavior This is relatively fast (almost as fast as the next alternative, the one we chose), but the implementation is ugly, in that we need to perform the same operation in many places around the code. If we want performance, probably the next alternative is better; if we want to be informative, then the first one is better (maybe in combination with the third one too). - Chosen behavior Only logging request lines when the request is valid. For any invalid request, or even unsupported ones, the request line will be logged as "-". Thus: Request -> access log [4] "GET / HTTP/1.1" -> "GET / HTTP/1.1" OK "GET / HTTP/1.1" -> "GET / HTTP/1.1" [1] "GET / HTTP/2.1" -> "-" [3] "GET / HTTP/1." -> "-" "GET / food" -> "-" "GET / / HTTP/1.1" -> "GET / / HTTP/1.1" [2] "GET / / HTTP/1.1" -> "GET / / HTTP/1.1" [2] "GET food HTTP/1.1" -> "-" "OPTIONS * HTTP/1.1" -> "-" "FOOBAR baz HTTP/1.1"-> "-" "FOOBAR / HTTP/1.1" -> "FOOBAR / HTTP/1.1" "get / HTTP/1.1" -> "-" "" -> "-" This is less informative than previous behavior, but considering how inconsistent it was, and that RFC-complying agents will probably not send us such requests, we're ready to lose that information in the log. This is of course the fastest and simplest implementation we can get. We've chosen to implement this alternative in this patch. Since we modified the behavior, this patch also changes the affected tests. [1]: Multiple successive spaces as a token delimiter is allowed by the RFC, but it is discouraged, and considered a security risk. It is currently supported by Unit, but we will probably drop support for it in the future. [2]: Unit currently supports spaces in the request-target. This is a violation of the relevant RFC (linked below), and will be fixed in the future, and consider those targets as invalid, returning a 400 (Bad Request), and thus the log lines with the previous inconsistent behavior would be changed. [3]: Not yet supported. [4]: In the error log, regarding the "log_routes" conditional logging of the request line, we only need to log the request line if it was valid. It doesn't make sense to log "" or "-" in case that the request was invalid, since this is only useful for understanding decisions of the router. In this case, the access log is more appropriate, which shows that the request was invalid, and a 400 was returned. When the request line is valid, it is printed in the error log exactly as in the access log. Link: <https://datatracker.ietf.org/doc/html/rfc9112#section-3> Suggested-by: Liam Crilly <liam@nginx.com> Reviewed-by: Zhidao Hong <z.hong@f5.com> Cc: Timo Stark <t.stark@nginx.com> Cc: Andrei Zeliankou <zelenkov@nginx.com> Cc: Andrew Clayton <a.clayton@nginx.com> Cc: Artem Konev <a.konev@f5.com> Signed-off-by: Alejandro Colomar <alx@nginx.com>
2023-03-29Auto: mirroring installation structure in build tree.Alejandro Colomar1-9/+12
This makes the build tree more organized, which is good for adding new stuff. Now, it's useful for example for adding manual pages in man3/, but it may be useful in the future for example for extending the build system to run linters (e.g., clang-tidy(1), Clang analyzer, ...) on the C source code. Previously, the build tree was quite flat, and looked like this (after `./configure && make`): $ tree -I src build build ├── Makefile ├── autoconf.data ├── autoconf.err ├── echo ├── libnxt.a ├── nxt_auto_config.h ├── nxt_version.h ├── unitd └── unitd.8 1 directory, 9 files And after this patch, it looks like this: $ tree -I src build build ├── Makefile ├── autoconf.data ├── autoconf.err ├── bin │ └── echo ├── include │ ├── nxt_auto_config.h │ └── nxt_version.h ├── lib │ ├── libnxt.a │ └── unit │ └── modules ├── sbin │ └── unitd ├── share │ └── man │ └── man8 │ └── unitd.8 └── var ├── lib │ └── unit ├── log │ └── unit └── run └── unit 17 directories, 9 files It also solves one issue introduced in 5a37171f733f ("Added default values for pathnames."). Before that commit, it was possible to run unitd from the build system (`./build/unitd`). Now, since it expects files in a very specific location, that has been broken. By having a directory structure that mirrors the installation, it's possible to trick it to believe it's installed, and run it from there: $ ./configure --prefix=./build $ make $ ./build/sbin/unitd Fixes: 5a37171f733f ("Added default values for pathnames.") Reported-by: Liam Crilly <liam@nginx.com> Reviewed-by: Konstantin Pavlov <thresh@nginx.com> Reviewed-by: Andrew Clayton <a.clayton@nginx.com> Cc: Andrei Zeliankou <zelenkov@nginx.com> Cc: Zhidao Hong <z.hong@f5.com> Signed-off-by: Alejandro Colomar <alx@nginx.com>
2023-03-29Renamed --libstatedir to --statedir.Alejandro Colomar1-1/+1
In BSD systems, it's usually </var/db> or some other dir under </var> that is not </var/lib>, so $statedir is a more generic name. See hier(7). Reported-by: Andrei Zeliankou <zelenkov@nginx.com> Reported-by: Zhidao Hong <z.hong@f5.com> Reviewed-by: Konstantin Pavlov <thresh@nginx.com> Reviewed-by: Andrew Clayton <a.clayton@nginx.com> Cc: Liam Crilly <liam@nginx.com> Signed-off-by: Alejandro Colomar <alx@nginx.com>
2023-03-27Tests: relaxed jar glob.Konstantin Pavlov1-1/+1
We install jars with names like websocket-api-${NXT_JAVA_MODULE}-$NXT_VERSION.jar, which translates to versioned NXT_JAVA_MODULE in the packaging system, e.g. websocket-api-java11-1.30.0.jar.
2023-03-21Tests: added tests for the "log_route" option.Andrei Zeliankou1-0/+154
2023-03-14Tests: added Perl test with many responses using streaming body.Andrei Zeliankou2-0/+16
2023-03-07Tests: _clear_temp_dir() function introduced.Andrei Zeliankou1-26/+31
Also added temporary directory clearing after checking available modules to prevent garbage environment when tests start.
2023-02-21Tests: switched to using f-strings.Andrei Zeliankou74-778/+695
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.