|
|
@ -533,20 +533,22 @@ def test_session_vary_cookie(): |
|
|
|
app = flask.Flask(__name__) |
|
|
|
app = flask.Flask(__name__) |
|
|
|
app.secret_key = 'testkey' |
|
|
|
app.secret_key = 'testkey' |
|
|
|
|
|
|
|
|
|
|
|
@app.route('/set-session') |
|
|
|
@app.route('/set') |
|
|
|
def set_session(): |
|
|
|
def set_session(): |
|
|
|
flask.session['test'] = 'test' |
|
|
|
flask.session['test'] = 'test' |
|
|
|
return '' |
|
|
|
return '' |
|
|
|
|
|
|
|
|
|
|
|
@app.route('/get-session') |
|
|
|
@app.route('/get') |
|
|
|
def get_session(): |
|
|
|
def get(): |
|
|
|
s = flask.session.get('test') |
|
|
|
return flask.session.get('test') |
|
|
|
return '' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/get-session-with-dictionary') |
|
|
|
@app.route('/getitem') |
|
|
|
def get_session_with_dictionary(): |
|
|
|
def getitem(): |
|
|
|
s = flask.session['test'] |
|
|
|
return flask.session['test'] |
|
|
|
return '' |
|
|
|
|
|
|
|
|
|
|
|
@app.route('/setdefault') |
|
|
|
|
|
|
|
def setdefault(): |
|
|
|
|
|
|
|
return flask.session.setdefault('test', 'default') |
|
|
|
|
|
|
|
|
|
|
|
@app.route('/no-vary-header') |
|
|
|
@app.route('/no-vary-header') |
|
|
|
def no_vary_header(): |
|
|
|
def no_vary_header(): |
|
|
@ -554,18 +556,20 @@ def test_session_vary_cookie(): |
|
|
|
|
|
|
|
|
|
|
|
c = app.test_client() |
|
|
|
c = app.test_client() |
|
|
|
|
|
|
|
|
|
|
|
rv = c.get('/set-session') |
|
|
|
def expect(path, header=True): |
|
|
|
assert rv.headers['Vary'] == 'Cookie' |
|
|
|
rv = c.get(path) |
|
|
|
|
|
|
|
|
|
|
|
rv = c.get('/get-session') |
|
|
|
if header: |
|
|
|
assert rv.headers['Vary'] == 'Cookie' |
|
|
|
assert rv.headers['Vary'] == 'Cookie' |
|
|
|
|
|
|
|
else: |
|
|
|
rv = c.get('/get-session-with-dictionary') |
|
|
|
|
|
|
|
assert rv.headers['Vary'] == 'Cookie' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rv = c.get('/no-vary-header') |
|
|
|
|
|
|
|
assert 'Vary' not in rv.headers |
|
|
|
assert 'Vary' not in rv.headers |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect('/set') |
|
|
|
|
|
|
|
expect('/get') |
|
|
|
|
|
|
|
expect('/getitem') |
|
|
|
|
|
|
|
expect('/setdefault') |
|
|
|
|
|
|
|
expect('/no-vary-header', False) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_flashes(): |
|
|
|
def test_flashes(): |
|
|
|
app = flask.Flask(__name__) |
|
|
|
app = flask.Flask(__name__) |
|
|
|