(app, client, recwarn)
| 1892 | |
| 1893 | |
| 1894 | def test_max_cookie_size(app, client, recwarn): |
| 1895 | app.config["MAX_COOKIE_SIZE"] = 100 |
| 1896 | |
| 1897 | # outside app context, default to Werkzeug static value, |
| 1898 | # which is also the default config |
| 1899 | response = flask.Response() |
| 1900 | default = flask.Flask.default_config["MAX_COOKIE_SIZE"] |
| 1901 | assert response.max_cookie_size == default |
| 1902 | |
| 1903 | # inside app context, use app config |
| 1904 | with app.app_context(): |
| 1905 | assert flask.Response().max_cookie_size == 100 |
| 1906 | |
| 1907 | @app.route("/") |
| 1908 | def index(): |
| 1909 | r = flask.Response("", status=204) |
| 1910 | r.set_cookie("foo", "bar" * 100) |
| 1911 | return r |
| 1912 | |
| 1913 | client.get("/") |
| 1914 | assert len(recwarn) == 1 |
| 1915 | w = recwarn.pop() |
| 1916 | assert "cookie is too large" in str(w.message) |
| 1917 | |
| 1918 | app.config["MAX_COOKIE_SIZE"] = 0 |
| 1919 | |
| 1920 | client.get("/") |
| 1921 | assert len(recwarn) == 0 |
| 1922 | |
| 1923 | |
| 1924 | @require_cpython_gc |
nothing calls this directly
no test coverage detected