Raise ValueError when cookie max-age is not an integer (#2001)

* Raise valueerror when cookie max-age is not an integer
This commit is contained in:
Adam Hopkins
2021-01-19 01:11:39 +02:00
committed by GitHub
parent 7028eae083
commit 8f4e0ad3c8
2 changed files with 19 additions and 2 deletions

View File

@@ -162,7 +162,7 @@ def test_cookie_set_same_key(app):
assert response.cookies["test"] == "pass"
@pytest.mark.parametrize("max_age", ["0", 30, 30.0, 30.1, "30", "test"])
@pytest.mark.parametrize("max_age", ["0", 30, "30"])
def test_cookie_max_age(app, max_age):
cookies = {"test": "wait"}
@@ -204,6 +204,23 @@ def test_cookie_max_age(app, max_age):
assert cookie is None
@pytest.mark.parametrize("max_age", [30.0, 30.1, "test"])
def test_cookie_bad_max_age(app, max_age):
cookies = {"test": "wait"}
@app.get("/")
def handler(request):
response = text("pass")
response.cookies["test"] = "pass"
response.cookies["test"]["max-age"] = max_age
return response
request, response = app.test_client.get(
"/", cookies=cookies, raw_cookies=True
)
assert response.status == 500
@pytest.mark.parametrize(
"expires", [datetime.utcnow() + timedelta(seconds=60)]
)