@@ -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 (
@@ -279,6 +285,18 @@ def test_server_proxy_port_non_service_rewrite_response(
279
285
assert s .startswith ("GET /foo?token=" )
280
286
281
287
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
+
282
300
@pytest .mark .parametrize (
283
301
"requestpath,expected" ,
284
302
[
@@ -311,28 +329,48 @@ def test_server_proxy_mappath_callable(
311
329
requestpath , expected , a_server_port_and_token : Tuple [int , str ]
312
330
) -> None :
313
331
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 )
315
333
assert r .code == 200
316
334
s = r .read ().decode ("ascii" )
317
335
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
320
338
321
339
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 :
323
346
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 )
325
348
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
326
353
327
354
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 :
329
361
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" )
331
363
assert r .code == 200
332
364
s = r .read ().decode ("ascii" )
333
365
assert "X-Custom-Header: pytest-23456\n " in s
334
366
335
367
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
+
336
374
def test_server_content_encoding_header (
337
375
a_server_port_and_token : Tuple [int , str ]
338
376
) -> None :
@@ -498,14 +536,6 @@ def test_bad_server_proxy_url(
498
536
assert "X-ProxyContextPath" not in r .headers
499
537
500
538
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
539
@pytest .mark .parametrize (
510
540
"rawsocket_type" ,
511
541
[
0 commit comments