Skip to content

Commit 61c84a0

Browse files
andrey-zelenkovhongzhidao
authored andcommitted
tests: REQUEST_URI variable test with rewrite
1 parent 6d6c68c commit 61c84a0

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

test/test_python_application.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from packaging import version
1111

1212
from unit.applications.lang.python import ApplicationPython
13+
from unit.option import option
1314

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

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

68+
# REQUEST_URI unchanged
69+
70+
path = f'{option.test_dir}/python/variables'
71+
assert 'success' in client.conf(
72+
{
73+
"listeners": {"*:8080": {"pass": "routes"}},
74+
"routes": [
75+
{
76+
"action": {
77+
"rewrite": "/foo",
78+
"pass": "applications/variables",
79+
}
80+
}
81+
],
82+
"applications": {
83+
"variables": {
84+
"type": client.get_application_type(),
85+
"processes": {'spare': 0},
86+
"path": path,
87+
"working_directory": path,
88+
"module": "wsgi",
89+
}
90+
},
91+
}
92+
)
93+
94+
resp = client.http(
95+
f"""POST /bar HTTP/1.1
96+
Host: localhost
97+
Content-Length: 1
98+
Custom-Header: blah
99+
Content-Type: text/html
100+
Connection: close
101+
102+
a""".encode(),
103+
raw=True,
104+
)
105+
assert resp['headers']['Request-Uri'] == '/bar', 'REQUEST_URI unchanged'
106+
67107

68108
def test_python_application_query_string():
69109
client.load('query_string')

0 commit comments

Comments
 (0)