Skip to content

Commit

Permalink
tests(proxy-wasm) showcase that invalid characters in querystring are…
Browse files Browse the repository at this point in the history
… passed through.

This matches the plain Nginx behavior, and showcased in one of the tests.
  • Loading branch information
hishamhm committed Nov 22, 2024
1 parent fd0fdcc commit f22115b
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 2 deletions.
75 changes: 73 additions & 2 deletions t/03-proxy_wasm/hfuncs/111-proxy_set_http_request_header.t
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,78 @@ path:



=== TEST 16: proxy_wasm - set_http_request_header() sets ':method'
=== TEST 16: proxy_wasm - set_http_request_headers() setting ':path' with invalid querystring matches nginx behavior
See following test for a showcase of the nginx behavior.

--- wasm_modules: hostcalls
--- http_config eval
qq{
upstream test_upstream {
server unix:$ENV{TEST_NGINX_UNIX_SOCKET};
}

server {
listen unix:$ENV{TEST_NGINX_UNIX_SOCKET};

location / {
return 200 '(\$request_uri) (\$uri) (\$is_args) (\$args)\n';
}
}
}
--- config
location /set_by_proxy_wasm {
proxy_wasm hostcalls 'test=/t/set_request_header name=:path value=/test?foo=bár%20bla';
proxy_wasm hostcalls 'test=/t/log/request_path';
proxy_pass http://test_upstream$uri$is_args$args;
}
--- request
GET /set_by_proxy_wasm
--- response_body
(/test?foo=bár%20bla) (/test) (?) (foo=bár%20bla)
--- error_log
path: /test
--- no_error_log
[error]
[crit]



=== TEST 17: proxy_wasm - showcase that that path with invalid querystring passes through
This test is here just as documentation, but it showcases
the same behavior as set_http_request_headers(':path');
see previous test for the proxy-wasm behavior.

--- wasm_modules: hostcalls
--- http_config eval
qq{
upstream test_upstream {
server unix:$ENV{TEST_NGINX_UNIX_SOCKET};
}

server {
listen unix:$ENV{TEST_NGINX_UNIX_SOCKET};

location / {
return 200 '(\$request_uri) (\$uri) (\$is_args) (\$args)\n';
}
}
}
--- config
location /raw_nginx {
proxy_pass http://test_upstream$uri$is_args$args;
}
--- request
GET /raw_nginx?foo=bár%20bla
--- response_body
(/raw_nginx?foo=bár%20bla) (/raw_nginx) (?) (foo=bár%20bla)
--- no_error_log
[error]
[crit]
[alert]



=== TEST 18: proxy_wasm - set_http_request_header() sets ':method'
--- wasm_modules: hostcalls
--- http_config eval
qq{
Expand Down Expand Up @@ -453,7 +524,7 @@ POST



=== TEST 17: proxy_wasm - set_http_request_header() cannot set ':scheme'
=== TEST 19: proxy_wasm - set_http_request_header() cannot set ':scheme'
--- wasm_modules: hostcalls
--- http_config eval
qq{
Expand Down
28 changes: 28 additions & 0 deletions t/03-proxy_wasm/hfuncs/130-proxy_dispatch_http.t
Original file line number Diff line number Diff line change
Expand Up @@ -1357,3 +1357,31 @@ Hello back /dispatched?foo=bar /dispatched ? foo=bar
--- no_error_log
[error]
[crit]



=== TEST 52: proxy_wasm - dispatch_http_call() can use ':path' with querystring, passes through invalid characters
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- config
location /dispatched {
return 200 "Hello back $request_uri $uri $is_args $args";
}

location /t {
proxy_wasm hostcalls 'on=request_body \
test=/t/dispatch_http_call \
host=127.0.0.1:$TEST_NGINX_SERVER_PORT \
path=/dispatched?foo=bár%20bla \
on_http_call_response=echo_response_body';
echo failed;
}
--- request
GET /t

Hello world
--- response_body
Hello back /dispatched?foo=bár%20bla /dispatched ? foo=bár%20bla
--- no_error_log
[error]
[crit]

0 comments on commit f22115b

Please sign in to comment.