@@ -29,6 +29,7 @@ def test_dev() -> None:
29
29
"workers" : None ,
30
30
"root_path" : "" ,
31
31
"proxy_headers" : True ,
32
+ "forwarded_allow_ips" : None ,
32
33
}
33
34
assert "Using import string single_file_app:app" in result .output
34
35
assert (
@@ -71,6 +72,7 @@ def test_dev_args() -> None:
71
72
"workers" : None ,
72
73
"root_path" : "/api" ,
73
74
"proxy_headers" : False ,
75
+ "forwarded_allow_ips" : None ,
74
76
}
75
77
assert "Using import string single_file_app:api" in result .output
76
78
assert (
@@ -97,6 +99,36 @@ def test_run() -> None:
97
99
"workers" : None ,
98
100
"root_path" : "" ,
99
101
"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" : "*" ,
100
132
}
101
133
assert "Using import string single_file_app:app" in result .output
102
134
assert (
@@ -141,6 +173,7 @@ def test_run_args() -> None:
141
173
"workers" : 2 ,
142
174
"root_path" : "/api" ,
143
175
"proxy_headers" : False ,
176
+ "forwarded_allow_ips" : None ,
144
177
}
145
178
assert "Using import string single_file_app:api" in result .output
146
179
assert (
0 commit comments