@@ -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 (
@@ -279,6 +285,18 @@ def test_server_proxy_port_non_service_rewrite_response(
279285 assert s .startswith ("GET /foo?token=" )
280286
281287
288+ def test_server_proxy_command_callable (
289+ a_server_port_and_token : Tuple [int , str ]
290+ ) -> None :
291+ PORT , TOKEN = a_server_port_and_token
292+ r = request_get (PORT , "/python-http-callable-command/abc" , TOKEN )
293+ assert r .code == 200
294+ s = r .read ().decode ("ascii" )
295+ assert s .startswith ("GET /abc?token=" )
296+ assert "X-Forwarded-Context: /python-http-callable-command\n " in s
297+ assert "X-Proxycontextpath: /python-http-callable-command\n " in s
298+
299+
282300@pytest .mark .parametrize (
283301 "requestpath,expected" ,
284302 [
@@ -311,28 +329,48 @@ def test_server_proxy_mappath_callable(
311329 requestpath , expected , a_server_port_and_token : Tuple [int , str ]
312330) -> None :
313331 PORT , TOKEN = a_server_port_and_token
314- r = request_get (PORT , "/python-http-mappathf " + requestpath , TOKEN )
332+ r = request_get (PORT , "/python-http-callable-mappath " + requestpath , TOKEN )
315333 assert r .code == 200
316334 s = r .read ().decode ("ascii" )
317335 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
336+ assert "X-Forwarded-Context: /python-http-callable-mappath \n " in s
337+ assert "X-Proxycontextpath: /python-http-callable-mappath \n " in s
320338
321339
322- def test_server_proxy_remote (a_server_port_and_token : Tuple [int , str ]) -> None :
340+ @pytest .mark .parametrize (
341+ "name" , ["python-http-environment" , "python-http-callable-environment" ]
342+ )
343+ def test_server_proxy_environment (
344+ name : str , a_server_port_and_token : Tuple [int , str ]
345+ ) -> None :
323346 PORT , TOKEN = a_server_port_and_token
324- r = request_get (PORT , "/newproxy " , TOKEN , host = "127.0.0.1" )
347+ r = request_get (PORT , f"/ { name } /test " , TOKEN )
325348 assert r .code == 200
349+ s = r .read ().decode ("ascii" )
350+ assert s .startswith ("GET /test?token=" )
351+ assert f"X-Forwarded-Context: /{ name } \n " in s
352+ assert f"X-Proxycontextpath: /{ name } \n " in s
326353
327354
328- def test_server_request_headers (a_server_port_and_token : Tuple [int , str ]) -> None :
355+ @pytest .mark .parametrize (
356+ "name" , ["python-http-request-headers" , "python-http-callable-request-headers" ]
357+ )
358+ def test_server_proxy_request_headers (
359+ name , a_server_port_and_token : Tuple [int , str ]
360+ ) -> None :
329361 PORT , TOKEN = a_server_port_and_token
330- r = request_get (PORT , "/python-request-headers /" , TOKEN , host = "127.0.0.1" )
362+ r = request_get (PORT , f"/ { name } /" , TOKEN , host = "127.0.0.1" )
331363 assert r .code == 200
332364 s = r .read ().decode ("ascii" )
333365 assert "X-Custom-Header: pytest-23456\n " in s
334366
335367
368+ def test_server_proxy_remote (a_server_port_and_token : Tuple [int , str ]) -> None :
369+ PORT , TOKEN = a_server_port_and_token
370+ r = request_get (PORT , "/newproxy" , TOKEN , host = "127.0.0.1" )
371+ assert r .code == 200
372+
373+
336374def test_server_content_encoding_header (
337375 a_server_port_and_token : Tuple [int , str ]
338376) -> None :
@@ -498,14 +536,6 @@ def test_bad_server_proxy_url(
498536 assert "X-ProxyContextPath" not in r .headers
499537
500538
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-
509539@pytest .mark .parametrize (
510540 "rawsocket_type" ,
511541 [
0 commit comments