configure and check trusted_hosts

This commit is contained in:
David Lord 2024-11-12 20:32:53 -08:00
parent 10bdf61a0f
commit 4f7156f2c3
No known key found for this signature in database
GPG key ID: 43368A7AA8CC5926
4 changed files with 40 additions and 0 deletions

View file

@ -52,3 +52,19 @@ def test_limit_config(app: Flask):
assert r.max_content_length == 90
assert r.max_form_memory_size == 30
assert r.max_form_parts == 4
def test_trusted_hosts_config(app: Flask) -> None:
app.config["TRUSTED_HOSTS"] = ["example.test", ".other.test"]
@app.get("/")
def index() -> str:
return ""
client = app.test_client()
r = client.get(base_url="http://example.test")
assert r.status_code == 200
r = client.get(base_url="http://a.other.test")
assert r.status_code == 200
r = client.get(base_url="http://bad.test")
assert r.status_code == 400