(app: Flask)
| 23 | |
| 24 | |
| 25 | def test_limit_config(app: Flask): |
| 26 | app.config["MAX_CONTENT_LENGTH"] = 100 |
| 27 | app.config["MAX_FORM_MEMORY_SIZE"] = 50 |
| 28 | app.config["MAX_FORM_PARTS"] = 3 |
| 29 | r = Request({}) |
| 30 | |
| 31 | # no app context, use Werkzeug defaults |
| 32 | assert r.max_content_length is None |
| 33 | assert r.max_form_memory_size == 500_000 |
| 34 | assert r.max_form_parts == 1_000 |
| 35 | |
| 36 | # in app context, use config |
| 37 | with app.app_context(): |
| 38 | assert r.max_content_length == 100 |
| 39 | assert r.max_form_memory_size == 50 |
| 40 | assert r.max_form_parts == 3 |
| 41 | |
| 42 | # regardless of app context, use override |
| 43 | r.max_content_length = 90 |
| 44 | r.max_form_memory_size = 30 |
| 45 | r.max_form_parts = 4 |
| 46 | |
| 47 | assert r.max_content_length == 90 |
| 48 | assert r.max_form_memory_size == 30 |
| 49 | assert r.max_form_parts == 4 |
| 50 | |
| 51 | with app.app_context(): |
| 52 | assert r.max_content_length == 90 |
| 53 | assert r.max_form_memory_size == 30 |
| 54 | assert r.max_form_parts == 4 |
| 55 | |
| 56 | |
| 57 | def test_trusted_hosts_config(app: Flask) -> None: |
nothing calls this directly
no test coverage detected