Skip to content

Commit 965e1a1

Browse files
committed
Update tests for minimal encoding
1 parent 2ae398f commit 965e1a1

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

tests/test_proxies.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,28 @@ def request_get(port, path, token, host='localhost'):
2020
return h.getresponse()
2121

2222

23-
def test_server_proxy_url_encoding():
24-
special_path = quote('Hellö Wörld 🎉你好世界@±¥')
23+
def test_server_proxy_minimal_proxy_path_encoding():
24+
"""Test that we don't encode anything more than we must to have a valid web
25+
request."""
26+
special_path = quote("Hello world 123 åäö 🎉你好世界±¥ :/[]@!$&'()*+,;=-._~", safe=":/?#[]@!$&'()*+,;=-._~")
27+
# NOTE: we left out ?# as they would interact badly with our requests_get
28+
# function's ability to pass the token query parameter.
2529
test_url = '/python-http/' + special_path
2630
r = request_get(PORT, test_url, TOKEN)
2731
assert r.code == 200
2832
s = r.read().decode('ascii')
29-
assert s.startswith('GET /{}?token='.format(special_path))
33+
assert 'GET /{}?token='.format(special_path) in s
34+
35+
def test_server_proxy_minimal_proxy_path_encoding_complement():
36+
"""Test that we don't encode ?# as a complement to the other test."""
37+
test_url = '/python-http/?token={}#test'.format(TOKEN)
38+
h = HTTPConnection('localhost', PORT, 10)
39+
r = request_get(PORT, test_url, TOKEN)
40+
h.request('GET', test_url)
41+
return h.getresponse()
42+
assert r.code == 200
43+
s = r.read().decode('ascii')
44+
assert 'GET /{}?token='.format(test_url) in s
3045

3146

3247
def test_server_proxy_non_absolute():

0 commit comments

Comments
 (0)