forked from orbit-oss/flask
add Response.max_cookie_size config
This commit is contained in:
parent
465b48ed4e
commit
1ed756a523
6 changed files with 65 additions and 5 deletions
|
|
@ -1917,3 +1917,33 @@ def test_run_from_config(monkeypatch, host, port, expect_host, expect_port, app)
|
|||
monkeypatch.setattr(werkzeug.serving, 'run_simple', run_simple_mock)
|
||||
app.config['SERVER_NAME'] = 'pocoo.org:8080'
|
||||
app.run(host, port)
|
||||
|
||||
|
||||
def test_max_cookie_size(app, client, recwarn):
|
||||
app.config['MAX_COOKIE_SIZE'] = 100
|
||||
|
||||
# outside app context, default to Werkzeug static value,
|
||||
# which is also the default config
|
||||
response = flask.Response()
|
||||
default = flask.Flask.default_config['MAX_COOKIE_SIZE']
|
||||
assert response.max_cookie_size == default
|
||||
|
||||
# inside app context, use app config
|
||||
with app.app_context():
|
||||
assert flask.Response().max_cookie_size == 100
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
r = flask.Response('', status=204)
|
||||
r.set_cookie('foo', 'bar' * 100)
|
||||
return r
|
||||
|
||||
client.get('/')
|
||||
assert len(recwarn) == 1
|
||||
w = recwarn.pop()
|
||||
assert 'cookie is too large' in str(w.message)
|
||||
|
||||
app.config['MAX_COOKIE_SIZE'] = 0
|
||||
|
||||
client.get('/')
|
||||
assert len(recwarn) == 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue