diff options
-rw-r--r-- | service/pixelated/bitmask_libraries/session.py | 5 | ||||
-rw-r--r-- | service/test/unit/bitmask_libraries/test_session.py | 13 |
2 files changed, 18 insertions, 0 deletions
diff --git a/service/pixelated/bitmask_libraries/session.py b/service/pixelated/bitmask_libraries/session.py index 57929c65..e217c286 100644 --- a/service/pixelated/bitmask_libraries/session.py +++ b/service/pixelated/bitmask_libraries/session.py @@ -89,6 +89,11 @@ class LeapSession(object): unregister(events.KEYMANAGER_FINISHED_KEY_GENERATION, uid=self.account_email()) self.soledad.close() self.remove_from_cache() + self._close_account() + + def _close_account(self): + if self.account: + self.account.end_session() def remove_from_cache(self): key = SessionCache.session_key(self.provider, self.user_auth.username) diff --git a/service/test/unit/bitmask_libraries/test_session.py b/service/test/unit/bitmask_libraries/test_session.py index 9654e624..22c2b3d9 100644 --- a/service/test/unit/bitmask_libraries/test_session.py +++ b/service/test/unit/bitmask_libraries/test_session.py @@ -97,6 +97,19 @@ class SessionTest(AbstractLeapTest): self.assertIsNone(SessionCache.lookup_session(key)) @patch('pixelated.bitmask_libraries.session.register') + def test_close_ends_account_session(self, _): + account_mock = MagicMock() + email = 'someone@somedomain.tld' + self.provider.address_for.return_value = email + session = self._create_session() + session.account = account_mock + + with patch('pixelated.bitmask_libraries.session.unregister') as unregister_mock: + session.close() + + account_mock.end_session.assert_called_once_with() + + @patch('pixelated.bitmask_libraries.session.register') def test_session_fresh_is_initially_false(self, _): session = self._create_session() |