diff options
-rw-r--r-- | service/app/__init__.py | 4 | ||||
-rw-r--r-- | service/app/bitmask_libraries/smtp.py | 12 | ||||
-rw-r--r-- | service/app/pixelated_user_agent.py | 4 | ||||
-rw-r--r-- | service/test/__init__.py | 4 | ||||
-rw-r--r-- | service/test/adapter/__init__.py | 0 | ||||
-rw-r--r-- | service/test/adapter/mail_service_test.py | 1 | ||||
-rw-r--r-- | service/test/bitmask_libraries/leap_srp_test.py | 4 | ||||
-rw-r--r-- | service/test/bitmask_libraries/smtp_test.py | 8 |
8 files changed, 20 insertions, 17 deletions
diff --git a/service/app/__init__.py b/service/app/__init__.py index e69de29b..acb5b492 100644 --- a/service/app/__init__.py +++ b/service/app/__init__.py @@ -0,0 +1,4 @@ +import sys +import os + +sys.path.insert(0, os.environ['APP_ROOT']) diff --git a/service/app/bitmask_libraries/smtp.py b/service/app/bitmask_libraries/smtp.py index 0315b40a..5fa7ad70 100644 --- a/service/app/bitmask_libraries/smtp.py +++ b/service/app/bitmask_libraries/smtp.py @@ -37,7 +37,7 @@ class LeapSmtp(object): session = requests.session() cert_url = '%s/%s/cert' % (self._provider.api_uri, self._provider.api_version) - cookies = { "_session_id": self._srp_session.session_id } + cookies = {"_session_id": self._srp_session.session_id} response = requests.get(cert_url, verify=which_bundle(self._provider), cookies=cookies, timeout=self._provider.config.timeout_in_s) response.raise_for_status() @@ -48,10 +48,11 @@ class LeapSmtp(object): f.write(client_cert) def _client_cert_path(self): - return os.path.join(self._provider.config.leap_home, - "providers", - self._provider.domain, - "keys", "client", "smtp.pem") + return os.path.join( + self._provider.config.leap_home, + "providers", + self._provider.domain, + "keys", "client", "smtp.pem") def start(self): self._download_client_certificates() @@ -74,4 +75,3 @@ class LeapSmtp(object): self._smtp_service.doStop() self._smtp_port = None self._smtp_service = None - diff --git a/service/app/pixelated_user_agent.py b/service/app/pixelated_user_agent.py index ff20413f..bdfcc336 100644 --- a/service/app/pixelated_user_agent.py +++ b/service/app/pixelated_user_agent.py @@ -1,11 +1,7 @@ -import sys -import os import json import datetime import requests -sys.path.insert(0, os.environ['APP_ROOT']) - from flask import Flask, request, Response from search import SearchQuery from adapter.mail_service import MailService diff --git a/service/test/__init__.py b/service/test/__init__.py new file mode 100644 index 00000000..acb5b492 --- /dev/null +++ b/service/test/__init__.py @@ -0,0 +1,4 @@ +import sys +import os + +sys.path.insert(0, os.environ['APP_ROOT']) diff --git a/service/test/adapter/__init__.py b/service/test/adapter/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/service/test/adapter/__init__.py diff --git a/service/test/adapter/mail_service_test.py b/service/test/adapter/mail_service_test.py index 9f0ac616..dfaee058 100644 --- a/service/test/adapter/mail_service_test.py +++ b/service/test/adapter/mail_service_test.py @@ -4,6 +4,7 @@ import unittest from app.adapter.mail_service import MailService + class TestMailService(unittest.TestCase): def test_initialization(self): diff --git a/service/test/bitmask_libraries/leap_srp_test.py b/service/test/bitmask_libraries/leap_srp_test.py index a8b5b3fb..e10be216 100644 --- a/service/test/bitmask_libraries/leap_srp_test.py +++ b/service/test/bitmask_libraries/leap_srp_test.py @@ -1,7 +1,3 @@ -import sys -import os -sys.path.insert(0, os.environ['APP_ROOT']) - import json import unittest import binascii diff --git a/service/test/bitmask_libraries/smtp_test.py b/service/test/bitmask_libraries/smtp_test.py index 3982a50c..ed5fc520 100644 --- a/service/test/bitmask_libraries/smtp_test.py +++ b/service/test/bitmask_libraries/smtp_test.py @@ -1,9 +1,9 @@ +import os from mock import MagicMock, patch from abstract_leap_test import AbstractLeapTest from app.bitmask_libraries.smtp import LeapSmtp from httmock import all_requests, HTTMock, urlmatch -import os -import sys + @all_requests def not_found_mock(url, request): @@ -12,6 +12,7 @@ def not_found_mock(url, request): return {'status_code': 404, 'content': 'foobar'} + @urlmatch(netloc='api.some-server.test:4430', path='/1/cert') def ca_cert_mock(url, request): return { @@ -19,6 +20,7 @@ def ca_cert_mock(url, request): "content": "some content" } + class LeapSmtpTest(AbstractLeapTest): keymanager = MagicMock() @@ -26,7 +28,7 @@ class LeapSmtpTest(AbstractLeapTest): self.provider.fetch_smtp_json.return_value = { 'hosts': { 'leap-mx': { - 'hostname': 'smtp.some-sever.test', + 'hostname': 'smtp.some-sever.test', 'port': '1234' } } |