summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/crypto/tests
diff options
context:
space:
mode:
authorIvan Alejandro <ivanalejandro0@gmail.com>2015-02-05 16:23:05 -0300
committerIvan Alejandro <ivanalejandro0@gmail.com>2015-02-05 16:23:05 -0300
commit91f0a38f5911d0f26210f62a94ab46e741e30189 (patch)
treeb1ca4bcfab84ba9a8cec6baf9daf2c70cc22b6cd /src/leap/bitmask/crypto/tests
parente046eeb7355a2ce3856eedee08bbc3d73ed7bbaa (diff)
parent1fa295ecd6af5c2ea64e76418bd144f9ddf4c803 (diff)
Merge branch 'release/0.8.x' into develop
Diffstat (limited to 'src/leap/bitmask/crypto/tests')
-rw-r--r--src/leap/bitmask/crypto/tests/test_srpauth.py60
1 files changed, 10 insertions, 50 deletions
diff --git a/src/leap/bitmask/crypto/tests/test_srpauth.py b/src/leap/bitmask/crypto/tests/test_srpauth.py
index 511a12ed..d420ef93 100644
--- a/src/leap/bitmask/crypto/tests/test_srpauth.py
+++ b/src/leap/bitmask/crypto/tests/test_srpauth.py
@@ -27,6 +27,7 @@ import sys
import binascii
import requests
import mock
+import shutil
from functools import partial
@@ -42,6 +43,7 @@ from leap.bitmask.crypto import srpregister, srpauth
from leap.bitmask.crypto.tests import fake_provider
from leap.bitmask.util.request_helpers import get_content
from leap.common.testing.https_server import where
+from leap.common.files import mkdir_p
log.startLogging(sys.stdout)
@@ -118,6 +120,10 @@ class SRPAuthTestCase(unittest.TestCase):
self.old_cookie_get = self.auth_backend._session.cookies.get
self.old_auth = self.auth_backend.authenticate
+ # HACK: this is needed since it seems that the backend settings path is
+ # not using the right path
+ mkdir_p('config/leap')
+
def tearDown(self):
self.auth_backend._session.post = self.old_post
self.auth_backend._session.put = self.old_put
@@ -132,6 +138,10 @@ class SRPAuthTestCase(unittest.TestCase):
self.auth_backend._session.cookies.get = self.old_cookie_get
self.auth_backend.authenticate = self.old_auth
+ # HACK: see 'setUp'
+ if os.path.exists('config'):
+ shutil.rmtree('config')
+
# helper methods
def _get_https_uri(self):
@@ -711,56 +721,6 @@ class SRPAuthSingletonTestCase(unittest.TestCase):
self.assertEqual(obj1._SRPAuth__instance, obj2._SRPAuth__instance)
@deferred()
- def test_authenticate_notifies_gui(self):
- auth = srpauth.SRPAuth(ProviderConfig())
- auth._SRPAuth__instance.authenticate = mock.create_autospec(
- auth._SRPAuth__instance.authenticate,
- return_value=threads.deferToThread(lambda: None))
- auth._gui_notify = mock.create_autospec(
- auth._gui_notify)
-
- d = auth.authenticate("", "")
-
- def check(*args):
- auth._gui_notify.assert_called_once_with(None)
-
- d.addCallback(check)
- return d
-
- @deferred()
- def test_authenticate_errsback(self):
- auth = srpauth.SRPAuth(ProviderConfig())
- auth._SRPAuth__instance.authenticate = mock.create_autospec(
- auth._SRPAuth__instance.authenticate,
- return_value=threads.deferToThread(MagicMock(
- side_effect=Exception())))
- auth._gui_notify = mock.create_autospec(
- auth._gui_notify)
- auth._errback = mock.create_autospec(
- auth._errback)
-
- d = auth.authenticate("", "")
-
- def check(*args):
- self.assertFalse(auth._gui_notify.called)
- self.assertEqual(auth._errback.call_count, 1)
-
- d.addCallback(check)
- return d
-
- @deferred()
- def test_authenticate_runs_cleanly_when_raises(self):
- auth = srpauth.SRPAuth(ProviderConfig())
- auth._SRPAuth__instance.authenticate = mock.create_autospec(
- auth._SRPAuth__instance.authenticate,
- return_value=threads.deferToThread(MagicMock(
- side_effect=Exception())))
-
- d = auth.authenticate("", "")
-
- return d
-
- @deferred()
def test_authenticate_runs_cleanly(self):
auth = srpauth.SRPAuth(ProviderConfig())
auth._SRPAuth__instance.authenticate = mock.create_autospec(