From fa7886f89b99b52bcbed6b7d3577e7f1caace3df Mon Sep 17 00:00:00 2001 From: RamiC Date: Sat, 31 Oct 2015 09:56:28 +0200 Subject: Convert max_age argument to int when applicable --- pyramid/session.py | 2 +- pyramid/tests/test_session.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pyramid/session.py b/pyramid/session.py index 18aa41a0f..fa85fe69c 100644 --- a/pyramid/session.py +++ b/pyramid/session.py @@ -238,7 +238,7 @@ def BaseCookieSessionFactory( # configuration parameters _cookie_name = cookie_name - _cookie_max_age = max_age + _cookie_max_age = max_age if max_age is None else int(max_age) _cookie_path = path _cookie_domain = domain _cookie_secure = secure diff --git a/pyramid/tests/test_session.py b/pyramid/tests/test_session.py index 68741b265..82e4fb001 100644 --- a/pyramid/tests/test_session.py +++ b/pyramid/tests/test_session.py @@ -322,6 +322,10 @@ class TestBaseCookieSession(SharedCookieSessionTests, unittest.TestCase): request = testing.DummyRequest() self.assertRaises(ValueError, self._makeOne, request, reissue_time='invalid value') + def test_cookie_max_age_invalid(self): + request = testing.DummyRequest() + self.assertRaises(ValueError, self._makeOne, request, max_age='invalid value') + class TestSignedCookieSession(SharedCookieSessionTests, unittest.TestCase): def _makeOne(self, request, **kw): from pyramid.session import SignedCookieSessionFactory @@ -369,6 +373,10 @@ class TestSignedCookieSession(SharedCookieSessionTests, unittest.TestCase): request = testing.DummyRequest() self.assertRaises(ValueError, self._makeOne, request, reissue_time='invalid value') + def test_cookie_max_age_invalid(self): + request = testing.DummyRequest() + self.assertRaises(ValueError, self._makeOne, request, max_age='invalid value') + def test_custom_salt(self): import time request = testing.DummyRequest() -- cgit v1.2.3