diff options
author | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-07-31 13:05:12 +0200 |
---|---|---|
committer | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-08-11 17:00:31 +0200 |
commit | 12636acfa193fb6871367771582f43a95611bfba (patch) | |
tree | fc33a2c2c91cc28f62810b073f1c7a8756e5f7f5 | |
parent | 94a4e0ce68ba66e5888a7ad696dd891123962a75 (diff) |
Added mail_store to LeapSession.
- Issue #420
-rw-r--r-- | service/pixelated/bitmask_libraries/session.py | 9 | ||||
-rw-r--r-- | service/pixelated/maintenance.py | 2 | ||||
-rw-r--r-- | service/test/unit/bitmask_libraries/test_abstract_leap.py | 3 | ||||
-rw-r--r-- | service/test/unit/bitmask_libraries/test_session.py | 2 |
4 files changed, 11 insertions, 5 deletions
diff --git a/service/pixelated/bitmask_libraries/session.py b/service/pixelated/bitmask_libraries/session.py index b4015e09..2098c9ce 100644 --- a/service/pixelated/bitmask_libraries/session.py +++ b/service/pixelated/bitmask_libraries/session.py @@ -22,6 +22,7 @@ from leap.mail.incoming.service import IncomingMail from twisted.internet import reactor from .nicknym import NickNym from leap.auth import SRPAuth +from pixelated.adapter.mailstore import LeapMailStore from .soledad import SoledadSessionFactory from .smtp import LeapSmtp from leap.mail.imap.account import IMAPAccount @@ -45,6 +46,8 @@ class LeapSession(object): - ``user_auth`` the secure remote password session data after authenticating with LEAP. See http://en.wikipedia.org/wiki/Secure_Remote_Password_protocol (SRPSession) + - ``mail_store`` the MailStore to access the users mails + - ``soledad_session`` the soledad session. See https://leap.se/soledad (LeapSecureRemotePassword) - ``nicknym`` the nicknym instance. See https://leap.se/nicknym (NickNym) @@ -52,11 +55,12 @@ class LeapSession(object): - ``incoming_mail_fetcher`` Background job for fetching incoming mails from LEAP server (LeapIncomingMail) """ - def __init__(self, provider, user_auth, soledad_session, nicknym, soledad_account, incoming_mail_fetcher, smtp): + def __init__(self, provider, user_auth, mail_store, soledad_session, nicknym, soledad_account, incoming_mail_fetcher, smtp): self.smtp = smtp self.config = provider.config self.provider = provider self.user_auth = user_auth + self.mail_store = mail_store self.soledad_session = soledad_session self.nicknym = nicknym self.account = soledad_account @@ -116,6 +120,7 @@ class LeapSessionFactory(object): account_email = self._provider.address_for(username) soledad = SoledadSessionFactory.create(self._provider, auth.token, auth.uuid, password) + mail_store = LeapMailStore(soledad.soledad) nicknym = self._create_nicknym(account_email, auth.token, auth.uuid, soledad) account = self._create_account(account_email, soledad) @@ -123,7 +128,7 @@ class LeapSessionFactory(object): smtp = LeapSmtp(self._provider, auth, nicknym.keymanager) - return LeapSession(self._provider, auth, soledad, nicknym, account, deferred_incoming_mail_fetcher, smtp) + return LeapSession(self._provider, auth, mail_store, soledad, nicknym, account, deferred_incoming_mail_fetcher, smtp) def _lookup_session(self, key): global SESSIONS diff --git a/service/pixelated/maintenance.py b/service/pixelated/maintenance.py index 1b8a9bc9..4bb06ceb 100644 --- a/service/pixelated/maintenance.py +++ b/service/pixelated/maintenance.py @@ -18,7 +18,6 @@ import logging from mailbox import Maildir from twisted.internet import reactor, defer from twisted.internet.threads import deferToThread -from pixelated.adapter.mailstore import LeapMailStore from pixelated.config.leap import initialize_leap from pixelated.config import logger, arguments @@ -48,7 +47,6 @@ def initialize(): def execute_command(args, leap_session): def init_soledad(): - leap_session.mail_store = LeapMailStore(leap_session.soledad_session.soledad) return leap_session def get_soledad_handle(leap_session): diff --git a/service/test/unit/bitmask_libraries/test_abstract_leap.py b/service/test/unit/bitmask_libraries/test_abstract_leap.py index a61bbd39..521d9cd4 100644 --- a/service/test/unit/bitmask_libraries/test_abstract_leap.py +++ b/service/test/unit/bitmask_libraries/test_abstract_leap.py @@ -19,6 +19,7 @@ from uuid import uuid4 import os from mock import Mock, MagicMock +from pixelated.adapter.mailstore import MailStore class AbstractLeapTest(unittest.TestCase): @@ -46,3 +47,5 @@ class AbstractLeapTest(unittest.TestCase): self.soledad_account = MagicMock() self.mail_fetcher_mock = MagicMock() + + self.mail_store = MagicMock(spec=MailStore) diff --git a/service/test/unit/bitmask_libraries/test_session.py b/service/test/unit/bitmask_libraries/test_session.py index 3aa8c8c7..ad2b10d0 100644 --- a/service/test/unit/bitmask_libraries/test_session.py +++ b/service/test/unit/bitmask_libraries/test_session.py @@ -65,7 +65,7 @@ class SessionTest(AbstractLeapTest): self.soledad_session.sync.assert_called_once_with() def _create_session(self): - return LeapSession(self.provider, self.auth, self.soledad_session, self.nicknym, self.soledad_account, + return LeapSession(self.provider, self.auth, self.mail_store, self.soledad_session, self.nicknym, self.soledad_account, self.mail_fetcher_mock, self.smtp_mock) |