Merge branch 'master' into cookie-usability

This commit is contained in:
Raphael Deem
2017-01-25 21:24:30 -08:00
committed by GitHub
4 changed files with 33 additions and 12 deletions

View File

@@ -26,6 +26,26 @@ def test_cookies():
assert response.text == 'Cookies are: working!'
assert response_cookies['right_back'].value == 'at you'
@pytest.mark.parametrize("httponly,expected", [
(False, False),
(True, True),
])
def test_false_cookies(httponly, expected):
app = Sanic('test_text')
@app.route('/')
def handler(request):
response = text('Cookies are: {}'.format(request.cookies['test']))
response.cookies['right_back'] = 'at you'
response.cookies['right_back']['httponly'] = httponly
return response
request, response = sanic_endpoint_test(app)
response_cookies = SimpleCookie()
response_cookies.load(response.headers.get('Set-Cookie', {}))
'HttpOnly' in response_cookies == expected
def test_http2_cookies():
app = Sanic('test_http2_cookies')
@@ -74,4 +94,4 @@ def test_cookie_deletion():
assert int(response_cookies['i_want_to_die']['max-age']) == 0
with pytest.raises(KeyError):
hold_my_beer = response.cookies['i_never_existed']
hold_my_beer = response.cookies['i_never_existed']