summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/crypto
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2015-02-05 15:22:37 -0400
committerKali Kaneko <kali@leap.se>2015-02-05 15:22:37 -0400
commit8de591e85db21c8a189336c630408abdf7c85b1b (patch)
tree82d9fd7daebe5ee0a1bd5d099e8249ca97340508 /src/leap/bitmask/crypto
parente2043a930b9ef98ad68746a2f21585901117892a (diff)
parent1fa295ecd6af5c2ea64e76418bd144f9ddf4c803 (diff)
Merge tag '0.8.0' into debian/experimental
Tag leap.bitmask version 0.8.0 Conflicts: pkg/requirements.pip src/leap/bitmask/gui/mainwindow.py
Diffstat (limited to 'src/leap/bitmask/crypto')
-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(