diff options
| author | Hasan Ramezani <hasan.r67@gmail.com> | 2019-05-19 22:15:45 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-05-21 08:50:09 +0200 |
| commit | 9d6f981a66bd2c4188c4a3e08e4f36fc9c4882ef (patch) | |
| tree | 9b061285be81426ec542e7e67927a22e8f5b575b /tests/sessions_tests | |
| parent | df28ebd6c89d68e781020a6a4e8405c0154e8e40 (diff) | |
Fixed #28763 -- Allowed overriding the session cookie age with SessionStore.get_session_cookie_age().
Diffstat (limited to 'tests/sessions_tests')
| -rw-r--r-- | tests/sessions_tests/models.py | 3 | ||||
| -rw-r--r-- | tests/sessions_tests/tests.py | 12 |
2 files changed, 15 insertions, 0 deletions
diff --git a/tests/sessions_tests/models.py b/tests/sessions_tests/models.py index 4fa216d9e6..557dbf7865 100644 --- a/tests/sessions_tests/models.py +++ b/tests/sessions_tests/models.py @@ -38,3 +38,6 @@ class SessionStore(DBStore): obj.account_id = account_id return obj + + def get_session_cookie_age(self): + return 60 * 60 * 24 # One day. diff --git a/tests/sessions_tests/tests.py b/tests/sessions_tests/tests.py index e9896dc18a..24e4e0c81b 100644 --- a/tests/sessions_tests/tests.py +++ b/tests/sessions_tests/tests.py @@ -454,6 +454,7 @@ class DatabaseSessionWithTimeZoneTests(DatabaseSessionTests): class CustomDatabaseSessionTests(DatabaseSessionTests): backend = CustomDatabaseSession session_engine = 'sessions_tests.models' + custom_session_cookie_age = 60 * 60 * 24 # One day. def test_extra_session_field(self): # Set the account ID to be picked up by a custom session storage @@ -473,6 +474,17 @@ class CustomDatabaseSessionTests(DatabaseSessionTests): s = self.model.objects.get(session_key=self.session.session_key) self.assertIsNone(s.account_id) + def test_custom_expiry_reset(self): + self.session.set_expiry(None) + self.session.set_expiry(10) + self.session.set_expiry(None) + self.assertEqual(self.session.get_expiry_age(), self.custom_session_cookie_age) + + def test_default_expiry(self): + self.assertEqual(self.session.get_expiry_age(), self.custom_session_cookie_age) + self.session.set_expiry(0) + self.assertEqual(self.session.get_expiry_age(), self.custom_session_cookie_age) + class CacheDBSessionTests(SessionTestsMixin, TestCase): |
