summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/services
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/bitmask/services')
-rw-r--r--src/leap/bitmask/services/eip/tests/test_eipconfig.py3
-rw-r--r--src/leap/bitmask/services/eip/tests/test_providerbootstrapper.py24
-rw-r--r--src/leap/bitmask/services/eip/tests/test_vpngatewayselector.py15
3 files changed, 39 insertions, 3 deletions
diff --git a/src/leap/bitmask/services/eip/tests/test_eipconfig.py b/src/leap/bitmask/services/eip/tests/test_eipconfig.py
index f8489e07..76305e83 100644
--- a/src/leap/bitmask/services/eip/tests/test_eipconfig.py
+++ b/src/leap/bitmask/services/eip/tests/test_eipconfig.py
@@ -30,8 +30,7 @@ from mock import Mock
sample_config = {
- "gateways": [
- {
+ "gateways": [{
"capabilities": {
"adblock": False,
"filter_dns": True,
diff --git a/src/leap/bitmask/services/eip/tests/test_providerbootstrapper.py b/src/leap/bitmask/services/eip/tests/test_providerbootstrapper.py
index 93467d3a..b0685676 100644
--- a/src/leap/bitmask/services/eip/tests/test_providerbootstrapper.py
+++ b/src/leap/bitmask/services/eip/tests/test_providerbootstrapper.py
@@ -64,7 +64,10 @@ class ProviderBootstrapperTest(BaseLeapTest):
self.pb._check_name_resolution()
# Something highly likely to fail
self.pb._domain = "uquhqweuihowquie.abc.def"
- with self.assertRaises(socket.gaierror):
+
+ # In python 2.7.4 raises socket.error
+ # In python 2.7.5 raises socket.gaierror
+ with self.assertRaises((socket.gaierror, socket.error)):
self.pb._check_name_resolution()
@deferred()
@@ -441,6 +444,25 @@ class ProviderBootstrapperActiveTest(unittest.TestCase):
self.assertFalse(ProviderConfig.save.called)
@mock.patch(
+ 'leap.bitmask.config.providerconfig.ProviderConfig.get_domain',
+ lambda x: where('testdomain.com'))
+ def test_download_provider_info_not_modified_and_no_cacert(self):
+ self._setup_provider_config_with("1", tempfile.mkdtemp())
+ self._setup_providerbootstrapper(True)
+ provider_path = self._produce_dummy_provider_json()
+
+ # set mtime to something really new
+ os.utime(provider_path, (-1, time.time()))
+
+ with mock.patch.object(
+ ProviderConfig, 'get_api_uri',
+ return_value="https://localhost:%s" % (self.https_port,)):
+ self.pb._download_provider_info()
+ # we check that it doesn't save the provider
+ # config, because it's new enough
+ self.assertFalse(ProviderConfig.save.called)
+
+ @mock.patch(
'leap.bitmask.config.providerconfig.ProviderConfig.get_ca_cert_path',
lambda x: where('cacert.pem'))
def test_download_provider_info_modified(self):
diff --git a/src/leap/bitmask/services/eip/tests/test_vpngatewayselector.py b/src/leap/bitmask/services/eip/tests/test_vpngatewayselector.py
index f9a177a9..36f8a076 100644
--- a/src/leap/bitmask/services/eip/tests/test_vpngatewayselector.py
+++ b/src/leap/bitmask/services/eip/tests/test_vpngatewayselector.py
@@ -19,6 +19,7 @@ tests for vpngatewayselector
"""
import unittest
+import time
from leap.bitmask.services.eip.eipconfig import EIPConfig, VPNGatewaySelector
from leap.common.testing.basetest import BaseLeapTest
@@ -128,5 +129,19 @@ class VPNGatewaySelectorTest(BaseLeapTest):
self.assertEqual(gateways, [ips[4], ips[2], ips[3], ips[1]])
+class VPNGatewaySelectorDSTTest(VPNGatewaySelectorTest):
+ """
+ VPNGatewaySelector's tests.
+ It uses the opposite value of the current DST.
+ """
+ def setUp(self):
+ self._original_daylight = time.daylight
+ time.daylight = not time.daylight
+ VPNGatewaySelectorTest.setUp(self)
+
+ def tearDown(self):
+ VPNGatewaySelectorTest.tearDown(self)
+ time.daylight = self._original_daylight
+
if __name__ == "__main__":
unittest.main()