From 2ec7bcfd32c2151e2e42ae7b19631dcc4018f93e Mon Sep 17 00:00:00 2001 From: Folker Bernitt Date: Fri, 27 Mar 2015 11:14:14 +0100 Subject: Splitting certificate validation into provider and bootstrap certificate. - Issue #333 - Now a different certificate is used to communicate with the provider's HTTPS website than for all other connections, e.g. to the api --- service/test/unit/bitmask_libraries/test_certs.py | 24 +++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'service/test/unit/bitmask_libraries/test_certs.py') diff --git a/service/test/unit/bitmask_libraries/test_certs.py b/service/test/unit/bitmask_libraries/test_certs.py index 8caafe7e..3683f9ae 100644 --- a/service/test/unit/bitmask_libraries/test_certs.py +++ b/service/test/unit/bitmask_libraries/test_certs.py @@ -1,6 +1,6 @@ import unittest -from pixelated.bitmask_libraries.certs import which_bundle +from pixelated.bitmask_libraries.certs import which_bootstrap_bundle, which_bundle from pixelated.bitmask_libraries.config import AUTO_DETECT_CA_BUNDLE from mock import MagicMock, patch @@ -8,12 +8,28 @@ from mock import MagicMock, patch class CertsTest(unittest.TestCase): @patch('pixelated.bitmask_libraries.certs.os.path.isfile') - def test_that_which_bundle_returns_byte_string(self, mock_isfile): + @patch('pixelated.bitmask_libraries.certs.os.path.isdir') + def test_that_which_bootstrap_bundle_returns_byte_string(self, mock_isdir, mock_isfile): mock_isfile.return_value = True - config = MagicMock(ca_cert_bundle=AUTO_DETECT_CA_BUNDLE, certs_home='/some/path') + mock_isdir.return_value = True + config = MagicMock(bootstrap_ca_cert_bundle=AUTO_DETECT_CA_BUNDLE, certs_home='/some/path') provider = MagicMock(server_name=u'test.leap.net', config=config) - bundle = which_bundle(provider) + bundle = which_bootstrap_bundle(provider) self.assertEqual('/some/path/test.leap.net.ca.crt', bundle) self.assertEqual(str, type(bundle)) + + @patch('pixelated.bitmask_libraries.certs.os.path.isfile') + @patch('pixelated.bitmask_libraries.certs.os.path.isdir') + def test_that_which_bundle_returns_byte_string(self, mock_isdir, mock_isfile): + mock_isfile.return_value = True + mock_isdir.return_value = True + + config = MagicMock(bootstrap_ca_cert_bundle=AUTO_DETECT_CA_BUNDLE, ca_cert_bundle=None, leap_home='/some/leap/home', certs_home='/some/path') + provider = MagicMock(server_name=u'test.leap.net', config=config) + + bundle = which_bundle(provider) + + self.assertEqual('/some/leap/home/providers/test.leap.net/keys/client/provider.pem', bundle) + self.assertEqual(str, type(bundle)) -- cgit v1.2.3