From 06e8b6f6b0b758866c053762be4716d7050c1943 Mon Sep 17 00:00:00 2001 From: drebs Date: Thu, 23 Feb 2017 19:31:30 -0300 Subject: [refactor] use new soledad client parameter - Resolves: #8721 --- src/leap/bitmask/core/mail_services.py | 14 ++++---------- src/leap/bitmask/keymanager/testing/__init__.py | 2 +- src/leap/bitmask/mail/imap/service/imap-server.tac | 5 ++--- src/leap/bitmask/mail/testing/__init__.py | 14 +------------- src/leap/bitmask/mail/testing/common.py | 2 +- 5 files changed, 9 insertions(+), 28 deletions(-) (limited to 'src/leap/bitmask') diff --git a/src/leap/bitmask/core/mail_services.py b/src/leap/bitmask/core/mail_services.py index 98f88ad..17e5d09 100644 --- a/src/leap/bitmask/core/mail_services.py +++ b/src/leap/bitmask/core/mail_services.py @@ -112,12 +112,6 @@ class SoledadContainer(Container): secrets_path = os.path.join(soledad_path, '%s.secret' % uuid) local_db_path = os.path.join(soledad_path, '%s.db' % uuid) - if token is None: - syncable = False - token = '' - else: - syncable = True - return Soledad( uuid, unicode(passphrase), @@ -126,14 +120,14 @@ class SoledadContainer(Container): server_url=server_url, cert_file=cert_file, auth_token=token, - syncable=syncable) + offline=True) def set_remote_auth_token(self, userid, token): self.get_instance(userid).token = token - def set_syncable(self, userid, state): + def set_offline(self, userid, state): # TODO should check that there's a token! - self.get_instance(userid).set_syncable(bool(state)) + self.get_instance(userid).set_offline(bool(state)) def sync(self, userid): self.get_instance(userid).sync() @@ -206,7 +200,7 @@ class SoledadService(HookableService): if container.get_instance(userid): logger.debug("passing a new SRP Token to Soledad: %s" % userid) container.set_remote_auth_token(userid, token) - container.set_syncable(userid, True) + container.set_offline(userid, False) else: logger.debug("adding a new Soledad Instance: %s" % userid) container.add_instance( diff --git a/src/leap/bitmask/keymanager/testing/__init__.py b/src/leap/bitmask/keymanager/testing/__init__.py index 3a78c51..9001207 100644 --- a/src/leap/bitmask/keymanager/testing/__init__.py +++ b/src/leap/bitmask/keymanager/testing/__init__.py @@ -251,7 +251,7 @@ class KeyManagerWithSoledadTestCase(unittest.TestCase, BaseLeapTest): server_url='', cert_file=None, auth_token=None, - syncable=False + offline=True, ) def tearDown(self): diff --git a/src/leap/bitmask/mail/imap/service/imap-server.tac b/src/leap/bitmask/mail/imap/service/imap-server.tac index 9460198..a5c390f 100644 --- a/src/leap/bitmask/mail/imap/service/imap-server.tac +++ b/src/leap/bitmask/mail/imap/service/imap-server.tac @@ -42,7 +42,6 @@ from leap.bitmask.mail.imap.service import LeapIMAPFactory from leap.soledad.client import Soledad - # TODO should get this initializers from some authoritative mocked source # We might want to put them the soledad itself. @@ -67,7 +66,7 @@ def initialize_soledad(uuid, email, passwd, localdb, server_url, cert_file, - syncable=False) + offline=True) return soledad @@ -121,7 +120,7 @@ km_args = (userid, "https://localhost", soledad) km_kwargs = { "token": "", "ca_cert_path": "", - "api_uri": "", + "api_uri": "", "api_version": "", "uid": uuid, "gpgbinary": get_gpg_bin_path() diff --git a/src/leap/bitmask/mail/testing/__init__.py b/src/leap/bitmask/mail/testing/__init__.py index afb8e43..54aaa87 100644 --- a/src/leap/bitmask/mail/testing/__init__.py +++ b/src/leap/bitmask/mail/testing/__init__.py @@ -17,8 +17,6 @@ """ Base classes and keys for leap.mail tests. """ -import os -import distutils.spawn from mock import Mock from twisted.internet.defer import gatherResults from twisted.trial import unittest @@ -38,7 +36,6 @@ class defaultMockSharedDB(object): put_doc = Mock(side_effect=None) open = Mock(return_value=None) close = Mock(return_value=None) - syncable = True def __call__(self): return self @@ -58,7 +55,7 @@ class KeyManagerWithSoledadTestCase(unittest.TestCase, BaseLeapTest): cert_file=None, auth_token=None, shared_db=defaultMockSharedDB(), - syncable=False) + offline=True) self.km = self._key_manager() @@ -111,15 +108,6 @@ class KeyManagerWithSoledadTestCase(unittest.TestCase, BaseLeapTest): gpgbinary=self.gpg_binary_path, ca_cert_path=ca_cert_path) - def get_public_binary_key(self): - with open(PATH + '/fixtures/public_key.bin', 'r') as binary_public_key: - return binary_public_key.read() - - def get_private_binary_key(self): - with open( - PATH + '/fixtures/private_key.bin', 'r') as binary_private_key: - return binary_private_key.read() - # key 24D18DDF: public key "Leap Test Key " KEY_FINGERPRINT = "E36E738D69173C13D709E44F2F455E2824D18DDF" diff --git a/src/leap/bitmask/mail/testing/common.py b/src/leap/bitmask/mail/testing/common.py index 1bf1de2..c77148d 100644 --- a/src/leap/bitmask/mail/testing/common.py +++ b/src/leap/bitmask/mail/testing/common.py @@ -57,7 +57,7 @@ def _initialize_soledad(email, gnupg_home, tempdir): local_db_path, server_url, cert_file, - syncable=False) + offline=True) return soledad -- cgit v1.2.3