Skip to content

Tests: REQUEST_URI variable test with rewrite #1197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions test/test_python_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from packaging import version

from unit.applications.lang.python import ApplicationPython
from unit.option import option

prerequisites = {'modules': {'python': 'all'}}

Expand Down Expand Up @@ -64,6 +65,45 @@ def test_python_application_variables(date_to_sec_epoch, sec_epoch):
}, 'headers'
assert resp['body'] == body, 'body'

# REQUEST_URI unchanged

path = f'{option.test_dir}/python/variables'
assert 'success' in client.conf(
{
"listeners": {"*:8080": {"pass": "routes"}},
"routes": [
{
"action": {
"rewrite": "/foo",
"pass": "applications/variables",
}
}
],
"applications": {
"variables": {
"type": client.get_application_type(),
"processes": {'spare': 0},
"path": path,
"working_directory": path,
"module": "wsgi",
}
},
}
)

resp = client.http(
f"""POST /bar HTTP/1.1
Host: localhost
Content-Length: 1
Custom-Header: blah
Content-Type: text/html
Connection: close

a""".encode(),
raw=True,
)
assert resp['headers']['Request-Uri'] == '/bar', 'REQUEST_URI unchanged'


def test_python_application_query_string():
client.load('query_string')
Expand Down