Skip to content

Commit 2e81c2a

Browse files
committed
Add tests for fixed port servers
1 parent 7413a54 commit 2e81c2a

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

tests/resources/jupyter_server_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@
66
'command': ['python3', './tests/resources/httpinfo.py', '{port}'],
77
'absolute_url': True
88
},
9+
'python-http-port54321': {
10+
'command': ['python3', './tests/resources/httpinfo.py', '{port}'],
11+
'port': 54321,
12+
},
913
}
1014
#c.Application.log_level = 'DEBUG'

tests/test_proxies.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,33 @@ def test_server_proxy_absolute():
2727
assert s.startswith('GET /python-http-abs/def?token=')
2828
assert 'X-Forwarded-Context' not in s
2929
assert 'X-Proxycontextpath' not in s
30+
31+
32+
def test_server_proxy_requested_port():
33+
r = request_get(PORT, '/python-http-port54321/ghi', TOKEN)
34+
assert r.code == 200
35+
s = r.read().decode('ascii')
36+
assert s.startswith('GET /ghi?token=')
37+
assert 'X-Forwarded-Context: /python-http-port54321\n' in s
38+
assert 'X-Proxycontextpath: /python-http-port54321\n' in s
39+
40+
direct = request_get(54321, '/ghi', TOKEN)
41+
assert direct.code == 200
42+
43+
44+
def test_server_proxy_port_non_absolute():
45+
r = request_get(PORT, '/proxy/54321/jkl', TOKEN)
46+
assert r.code == 200
47+
s = r.read().decode('ascii')
48+
assert s.startswith('GET /jkl?token=')
49+
assert 'X-Forwarded-Context: /proxy/54321\n' in s
50+
assert 'X-Proxycontextpath: /proxy/54321\n' in s
51+
52+
53+
def test_server_proxy_port_absolute():
54+
r = request_get(PORT, '/proxy/absolute/54321/nmo', TOKEN)
55+
assert r.code == 200
56+
s = r.read().decode('ascii')
57+
assert s.startswith('GET /proxy/absolute/54321/nmo?token=')
58+
assert 'X-Forwarded-Context' not in s
59+
assert 'X-Proxycontextpath' not in s

0 commit comments

Comments
 (0)