@@ -33,6 +33,12 @@ def request_get(port, path, token, host=LOCALHOST):
3333 sys .platform == "win32" , reason = "Unix socket not supported on Windows"
3434 ),
3535 ),
36+ pytest .param (
37+ "/python-unix-socket-callable/" ,
38+ marks = pytest .mark .skipif (
39+ sys .platform == "win32" , reason = "Unix socket not supported on Windows"
40+ ),
41+ ),
3642 pytest .param (
3743 "/python-unix-socket-file/" ,
3844 marks = pytest .mark .skipif (
@@ -278,6 +284,17 @@ def test_server_proxy_port_non_service_rewrite_response(
278284 s = r .read ().decode ("ascii" )
279285 assert s .startswith ("GET /foo?token=" )
280286
287+ def test_server_proxy_command_callable (
288+ a_server_port_and_token : Tuple [int , str ]
289+ ) -> None :
290+ PORT , TOKEN = a_server_port_and_token
291+ r = request_get (PORT , "/python-http-callable-command/abc" , TOKEN )
292+ assert r .code == 200
293+ s = r .read ().decode ("ascii" )
294+ assert s .startswith ("GET /abc?token=" )
295+ assert "X-Forwarded-Context: /python-http-callable-command\n " in s
296+ assert "X-Proxycontextpath: /python-http-callable-command\n " in s
297+
281298
282299@pytest .mark .parametrize (
283300 "requestpath,expected" ,
@@ -311,26 +328,40 @@ def test_server_proxy_mappath_callable(
311328 requestpath , expected , a_server_port_and_token : Tuple [int , str ]
312329) -> None :
313330 PORT , TOKEN = a_server_port_and_token
314- r = request_get (PORT , "/python-http-mappathf " + requestpath , TOKEN )
331+ r = request_get (PORT , "/python-http-callable-mappath " + requestpath , TOKEN )
315332 assert r .code == 200
316333 s = r .read ().decode ("ascii" )
317334 assert s .startswith ("GET " + expected )
318- assert "X-Forwarded-Context: /python-http-mappathf \n " in s
319- assert "X-Proxycontextpath: /python-http-mappathf \n " in s
335+ assert "X-Forwarded-Context: /python-http-callable-mappath \n " in s
336+ assert "X-Proxycontextpath: /python-http-callable-mappath \n " in s
320337
321338
322- def test_server_proxy_remote (a_server_port_and_token : Tuple [int , str ]) -> None :
339+ @pytest .mark .parametrize ("name" , ["python-http-environment" , "python-http-callable-environment" ])
340+ def test_server_proxy_environment (
341+ name : str , a_server_port_and_token : Tuple [int , str ]
342+ ) -> None :
323343 PORT , TOKEN = a_server_port_and_token
324- r = request_get (PORT , "/newproxy " , TOKEN , host = "127.0.0.1" )
344+ r = request_get (PORT , f"/ { name } /test " , TOKEN )
325345 assert r .code == 200
346+ s = r .read ().decode ("ascii" )
347+ assert s .startswith ("GET /test?token=" )
348+ assert f"X-Forwarded-Context: /{ name } \n " in s
349+ assert f"X-Proxycontextpath: /{ name } \n " in s
326350
327351
328- def test_server_request_headers (a_server_port_and_token : Tuple [int , str ]) -> None :
352+ @pytest .mark .parametrize ("name" , ["python-http-request-headers" , "python-http-callable-request-headers" ])
353+ def test_server_proxy_request_headers (name , a_server_port_and_token : Tuple [int , str ]) -> None :
329354 PORT , TOKEN = a_server_port_and_token
330- r = request_get (PORT , "/python-request-headers /" , TOKEN , host = "127.0.0.1" )
355+ r = request_get (PORT , f"/ { name } /" , TOKEN , host = "127.0.0.1" )
331356 assert r .code == 200
332357 s = r .read ().decode ("ascii" )
333- assert "X-Custom-Header: pytest-23456\n " in s
358+ assert f"X-Custom-Header: pytest-23456\n " in s
359+
360+
361+ def test_server_proxy_remote (a_server_port_and_token : Tuple [int , str ]) -> None :
362+ PORT , TOKEN = a_server_port_and_token
363+ r = request_get (PORT , "/newproxy" , TOKEN , host = "127.0.0.1" )
364+ assert r .code == 200
334365
335366
336367def test_server_content_encoding_header (
@@ -498,14 +529,6 @@ def test_bad_server_proxy_url(
498529 assert "X-ProxyContextPath" not in r .headers
499530
500531
501- def test_callable_environment_formatting (
502- a_server_port_and_token : Tuple [int , str ]
503- ) -> None :
504- PORT , TOKEN = a_server_port_and_token
505- r = request_get (PORT , "/python-http-callable-env/test" , TOKEN )
506- assert r .code == 200
507-
508-
509532@pytest .mark .parametrize (
510533 "rawsocket_type" ,
511534 [
0 commit comments