summaryrefslogtreecommitdiff
path: root/src/leap/bitmask
diff options
context:
space:
mode:
authorIvan Alejandro <ivanalejandro0@gmail.com>2013-08-13 10:45:04 -0300
committerIvan Alejandro <ivanalejandro0@gmail.com>2013-08-13 10:45:04 -0300
commit82238ca905804d4a219286f14a86297a2d0d7d27 (patch)
tree334b14002c947ac5d67d47f01d4302d4b067ff67 /src/leap/bitmask
parent9c7a740679122b42efbc2f02ea0235c690b1ab8f (diff)
Update mocks for the new namespace. Closes #3445.
Diffstat (limited to 'src/leap/bitmask')
-rw-r--r--src/leap/bitmask/crypto/tests/test_srpauth.py34
-rw-r--r--src/leap/bitmask/services/eip/tests/test_providerbootstrapper.py30
2 files changed, 35 insertions, 29 deletions
diff --git a/src/leap/bitmask/crypto/tests/test_srpauth.py b/src/leap/bitmask/crypto/tests/test_srpauth.py
index 043da15e..44cd6334 100644
--- a/src/leap/bitmask/crypto/tests/test_srpauth.py
+++ b/src/leap/bitmask/crypto/tests/test_srpauth.py
@@ -247,9 +247,9 @@ class SRPAuthTestCase(unittest.TestCase):
def wrapper(_):
with self.assertRaises(srpauth.SRPAuthUnknownUser):
- with mock.patch('leap.util.request_helpers.get_content',
- new=mock.create_autospec(get_content)) as \
- content:
+ with mock.patch(
+ 'leap.bitmask.util.request_helpers.get_content',
+ new=mock.create_autospec(get_content)) as content:
content.return_value = ("{}", 0)
self.auth_backend._start_authentication(
@@ -264,9 +264,9 @@ class SRPAuthTestCase(unittest.TestCase):
def wrapper(_):
with self.assertRaises(srpauth.SRPAuthBadStatusCode):
- with mock.patch('leap.util.request_helpers.get_content',
- new=mock.create_autospec(get_content)) as \
- content:
+ with mock.patch(
+ 'leap.bitmask.util.request_helpers.get_content',
+ new=mock.create_autospec(get_content)) as content:
content.return_value = ("{}", 0)
self.auth_backend._start_authentication(None,
@@ -281,9 +281,9 @@ class SRPAuthTestCase(unittest.TestCase):
def wrapper(_):
with self.assertRaises(srpauth.SRPAuthNoSalt):
- with mock.patch('leap.util.request_helpers.get_content',
- new=mock.create_autospec(get_content)) as \
- content:
+ with mock.patch(
+ 'leap.bitmask.util.request_helpers.get_content',
+ new=mock.create_autospec(get_content)) as content:
content.return_value = ("{}", 0)
self.auth_backend._start_authentication(None,
@@ -298,9 +298,9 @@ class SRPAuthTestCase(unittest.TestCase):
def wrapper(_):
with self.assertRaises(srpauth.SRPAuthNoB):
- with mock.patch('leap.util.request_helpers.get_content',
- new=mock.create_autospec(get_content)) as \
- content:
+ with mock.patch(
+ 'leap.bitmask.util.request_helpers.get_content',
+ new=mock.create_autospec(get_content)) as content:
content.return_value = ('{"salt": ""}', 0)
self.auth_backend._start_authentication(None,
@@ -317,7 +317,7 @@ class SRPAuthTestCase(unittest.TestCase):
test_B = "67890"
def wrapper(_):
- with mock.patch('leap.util.request_helpers.get_content',
+ with mock.patch('leap.bitmask.util.request_helpers.get_content',
new=mock.create_autospec(get_content)) as \
content:
content.return_value = ('{"salt":"%s", "B":"%s"}' % (test_salt,
@@ -395,7 +395,7 @@ class SRPAuthTestCase(unittest.TestCase):
d = self._prepare_auth_challenge()
def wrapper(salt_B):
- with mock.patch('leap.util.request_helpers.get_content',
+ with mock.patch('leap.bitmask.util.request_helpers.get_content',
new=mock.create_autospec(get_content)) as \
content:
content.return_value = ("{", 0)
@@ -421,7 +421,7 @@ class SRPAuthTestCase(unittest.TestCase):
return_value=res)
def wrapper(salt_B):
- with mock.patch('leap.util.request_helpers.get_content',
+ with mock.patch('leap.bitmask.util.request_helpers.get_content',
new=mock.create_autospec(get_content)) as \
content:
content.return_value = ("", 0)
@@ -445,7 +445,7 @@ class SRPAuthTestCase(unittest.TestCase):
return_value=res)
def wrapper(salt_B):
- with mock.patch('leap.util.request_helpers.get_content',
+ with mock.patch('leap.bitmask.util.request_helpers.get_content',
new=mock.create_autospec(get_content)) as \
content:
content.return_value = ("[]", 0)
@@ -469,7 +469,7 @@ class SRPAuthTestCase(unittest.TestCase):
return_value=res)
def wrapper(salt_B):
- with mock.patch('leap.util.request_helpers.get_content',
+ with mock.patch('leap.bitmask.util.request_helpers.get_content',
new=mock.create_autospec(get_content)) as \
content:
content.return_value = ("{}", 0)
diff --git a/src/leap/bitmask/services/eip/tests/test_providerbootstrapper.py b/src/leap/bitmask/services/eip/tests/test_providerbootstrapper.py
index 96ab53ce..93467d3a 100644
--- a/src/leap/bitmask/services/eip/tests/test_providerbootstrapper.py
+++ b/src/leap/bitmask/services/eip/tests/test_providerbootstrapper.py
@@ -421,8 +421,9 @@ class ProviderBootstrapperActiveTest(unittest.TestCase):
self.pb._download_provider_info()
self.assertTrue(ProviderConfig.save.called)
- @mock.patch('leap.config.providerconfig.ProviderConfig.get_ca_cert_path',
- lambda x: where('cacert.pem'))
+ @mock.patch(
+ 'leap.bitmask.config.providerconfig.ProviderConfig.get_ca_cert_path',
+ lambda x: where('cacert.pem'))
def test_download_provider_info_not_modified(self):
self._setup_provider_config_with("1", tempfile.mkdtemp())
self._setup_providerbootstrapper(True)
@@ -439,8 +440,9 @@ class ProviderBootstrapperActiveTest(unittest.TestCase):
# config, because it's new enough
self.assertFalse(ProviderConfig.save.called)
- @mock.patch('leap.config.providerconfig.ProviderConfig.get_ca_cert_path',
- lambda x: where('cacert.pem'))
+ @mock.patch(
+ 'leap.bitmask.config.providerconfig.ProviderConfig.get_ca_cert_path',
+ lambda x: where('cacert.pem'))
def test_download_provider_info_modified(self):
self._setup_provider_config_with("1", tempfile.mkdtemp())
self._setup_providerbootstrapper(True)
@@ -456,8 +458,9 @@ class ProviderBootstrapperActiveTest(unittest.TestCase):
self.assertTrue(ProviderConfig.load.called)
self.assertTrue(ProviderConfig.save.called)
- @mock.patch('leap.config.providerconfig.ProviderConfig.get_ca_cert_path',
- lambda x: where('cacert.pem'))
+ @mock.patch(
+ 'leap.bitmask.config.providerconfig.ProviderConfig.get_ca_cert_path',
+ lambda x: where('cacert.pem'))
def test_download_provider_info_unsupported_api_raises(self):
self._setup_provider_config_with("9999999", tempfile.mkdtemp())
self._setup_providerbootstrapper(False)
@@ -469,8 +472,9 @@ class ProviderBootstrapperActiveTest(unittest.TestCase):
with self.assertRaises(UnsupportedProviderAPI):
self.pb._download_provider_info()
- @mock.patch('leap.config.providerconfig.ProviderConfig.get_ca_cert_path',
- lambda x: where('cacert.pem'))
+ @mock.patch(
+ 'leap.bitmask.config.providerconfig.ProviderConfig.get_ca_cert_path',
+ lambda x: where('cacert.pem'))
def test_download_provider_info_unsupported_api(self):
self._setup_provider_config_with(SupportedAPIs.SUPPORTED_APIS[0],
tempfile.mkdtemp())
@@ -482,10 +486,12 @@ class ProviderBootstrapperActiveTest(unittest.TestCase):
return_value="https://localhost:%s" % (self.https_port,)):
self.pb._download_provider_info()
- @mock.patch('leap.config.providerconfig.ProviderConfig.get_api_uri',
- lambda x: 'api.uri')
- @mock.patch('leap.config.providerconfig.ProviderConfig.get_ca_cert_path',
- lambda x: '/cert/path')
+ @mock.patch(
+ 'leap.bitmask.config.providerconfig.ProviderConfig.get_api_uri',
+ lambda x: 'api.uri')
+ @mock.patch(
+ 'leap.bitmask.config.providerconfig.ProviderConfig.get_ca_cert_path',
+ lambda x: '/cert/path')
def test_check_api_certificate_skips(self):
self.pb._provider_config = ProviderConfig()
self.pb._session.get = mock.MagicMock(return_value=Response())