@@ -33,6 +33,12 @@ def request_get(port, path, token, host=LOCALHOST):
33
33
sys .platform == "win32" , reason = "Unix socket not supported on Windows"
34
34
),
35
35
),
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
+ ),
36
42
pytest .param (
37
43
"/python-unix-socket-file/" ,
38
44
marks = pytest .mark .skipif (
@@ -278,6 +284,17 @@ def test_server_proxy_port_non_service_rewrite_response(
278
284
s = r .read ().decode ("ascii" )
279
285
assert s .startswith ("GET /foo?token=" )
280
286
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
+
281
298
282
299
@pytest .mark .parametrize (
283
300
"requestpath,expected" ,
@@ -311,26 +328,40 @@ def test_server_proxy_mappath_callable(
311
328
requestpath , expected , a_server_port_and_token : Tuple [int , str ]
312
329
) -> None :
313
330
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 )
315
332
assert r .code == 200
316
333
s = r .read ().decode ("ascii" )
317
334
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
320
337
321
338
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 :
323
343
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 )
325
345
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
326
350
327
351
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 :
329
354
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" )
331
356
assert r .code == 200
332
357
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
334
365
335
366
336
367
def test_server_content_encoding_header (
@@ -498,14 +529,6 @@ def test_bad_server_proxy_url(
498
529
assert "X-ProxyContextPath" not in r .headers
499
530
500
531
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
-
509
532
@pytest .mark .parametrize (
510
533
"rawsocket_type" ,
511
534
[
0 commit comments