(app, client, recwarn)
| 1920 | |
| 1921 | |
| 1922 | def test_max_cookie_size(app, client, recwarn): |
| 1923 | app.config["MAX_COOKIE_SIZE"] = 100 |
| 1924 | |
| 1925 | # outside app context, default to Werkzeug static value, |
| 1926 | # which is also the default config |
| 1927 | response = flask.Response() |
| 1928 | default = flask.Flask.default_config["MAX_COOKIE_SIZE"] |
| 1929 | assert response.max_cookie_size == default |
| 1930 | |
| 1931 | # inside app context, use app config |
| 1932 | with app.app_context(): |
| 1933 | assert flask.Response().max_cookie_size == 100 |
| 1934 | |
| 1935 | @app.route("/") |
| 1936 | def index(): |
| 1937 | r = flask.Response("", status=204) |
| 1938 | r.set_cookie("foo", "bar" * 100) |
| 1939 | return r |
| 1940 | |
| 1941 | client.get("/") |
| 1942 | assert len(recwarn) == 1 |
| 1943 | w = recwarn.pop() |
| 1944 | assert "cookie is too large" in str(w.message) |
| 1945 | |
| 1946 | app.config["MAX_COOKIE_SIZE"] = 0 |
| 1947 | |
| 1948 | client.get("/") |
| 1949 | assert len(recwarn) == 0 |
| 1950 | |
| 1951 | |
| 1952 | @require_cpython_gc |
nothing calls this directly
no test coverage detected