@@ -29,6 +29,7 @@ def test_dev() -> None:
2929 "workers" : None ,
3030 "root_path" : "" ,
3131 "proxy_headers" : True ,
32+ "forwarded_allow_ips" : None ,
3233 }
3334 assert "Using import string single_file_app:app" in result .output
3435 assert (
@@ -71,6 +72,7 @@ def test_dev_args() -> None:
7172 "workers" : None ,
7273 "root_path" : "/api" ,
7374 "proxy_headers" : False ,
75+ "forwarded_allow_ips" : None ,
7476 }
7577 assert "Using import string single_file_app:api" in result .output
7678 assert (
@@ -97,6 +99,36 @@ def test_run() -> None:
9799 "workers" : None ,
98100 "root_path" : "" ,
99101 "proxy_headers" : True ,
102+ "forwarded_allow_ips" : None ,
103+ }
104+ assert "Using import string single_file_app:app" in result .output
105+ assert (
106+ "╭─────────── FastAPI CLI - Production mode ───────────╮" in result .output
107+ )
108+ assert "│ Serving at: http://0.0.0.0:8000" in result .output
109+ assert "│ API docs: http://0.0.0.0:8000/docs" in result .output
110+ assert "│ Running in production mode, for development use:" in result .output
111+ assert "│ fastapi dev" in result .output
112+
113+
114+ def test_run_trust_proxy () -> None :
115+ with changing_dir (assets_path ):
116+ with patch .object (uvicorn , "run" ) as mock_run :
117+ result = runner .invoke (
118+ app , ["run" , "single_file_app.py" , "--forwarded-allow-ips" , "*" ]
119+ )
120+ assert result .exit_code == 0 , result .output
121+ assert mock_run .called
122+ assert mock_run .call_args
123+ assert mock_run .call_args .kwargs == {
124+ "app" : "single_file_app:app" ,
125+ "host" : "0.0.0.0" ,
126+ "port" : 8000 ,
127+ "reload" : False ,
128+ "workers" : None ,
129+ "root_path" : "" ,
130+ "proxy_headers" : True ,
131+ "forwarded_allow_ips" : "*" ,
100132 }
101133 assert "Using import string single_file_app:app" in result .output
102134 assert (
@@ -141,6 +173,7 @@ def test_run_args() -> None:
141173 "workers" : 2 ,
142174 "root_path" : "/api" ,
143175 "proxy_headers" : False ,
176+ "forwarded_allow_ips" : None ,
144177 }
145178 assert "Using import string single_file_app:api" in result .output
146179 assert (
0 commit comments