diff options
author | kali <kali@leap.se> | 2012-09-06 04:20:23 +0900 |
---|---|---|
committer | kali <kali@leap.se> | 2012-09-06 04:20:23 +0900 |
commit | bb5d092b6f57321a12f0d7575e221b0cc68f063d (patch) | |
tree | f8edf58ebdef82a0229739f62fb0d9fbcb633a2a /src/leap/eip/tests | |
parent | 75f4128f5ed515c4df57275bf1479ccdf741c83f (diff) | |
parent | fc8a54a40645412e9c738723e54159bfda40cfde (diff) |
Merge branch 'feature/temp-socket-path' into develop
Closes #505: make management socket to listen on temporal files,
different for each run
Diffstat (limited to 'src/leap/eip/tests')
-rw-r--r-- | src/leap/eip/tests/test_config.py | 5 | ||||
-rw-r--r-- | src/leap/eip/tests/test_openvpnconnection.py | 39 |
2 files changed, 20 insertions, 24 deletions
diff --git a/src/leap/eip/tests/test_config.py b/src/leap/eip/tests/test_config.py index c73281cc..60300770 100644 --- a/src/leap/eip/tests/test_config.py +++ b/src/leap/eip/tests/test_config.py @@ -71,7 +71,7 @@ class EIPConfigTest(BaseLeapTest): args.append('--management') #XXX hey! #get platform switches here! - args.append('/tmp/.eip.sock') + args.append('/tmp/test.socket') args.append('unix') # certs @@ -114,7 +114,8 @@ class EIPConfigTest(BaseLeapTest): print 'path =', path print 'vpnbin = ', vpnbin command, args = eipconfig.build_ovpn_command( - do_pkexec_check=False, vpnbin=vpnbin) + do_pkexec_check=False, vpnbin=vpnbin, + socket_path="/tmp/test.socket") self.assertEqual(command, self.home + '/bin/openvpn') self.assertEqual(args, self.get_expected_openvpn_args()) diff --git a/src/leap/eip/tests/test_openvpnconnection.py b/src/leap/eip/tests/test_openvpnconnection.py index dea75b55..885c80b3 100644 --- a/src/leap/eip/tests/test_openvpnconnection.py +++ b/src/leap/eip/tests/test_openvpnconnection.py @@ -1,5 +1,7 @@ import logging +import os import platform +import shutil #import socket logging.basicConfig() @@ -12,9 +14,10 @@ except ImportError: from mock import Mock, patch # MagicMock +from leap.eip import config as eipconfig from leap.eip import openvpnconnection -from leap.eip import exceptions as eip_exceptions from leap.eip.udstelnet import UDSTelnet +from leap.testing.basetest import BaseLeapTest _system = platform.system() @@ -46,28 +49,25 @@ class MockedOpenVPNConnection(openvpnconnection.OpenVPNConnection): self.tn = mock_UDSTelnet(self.host, port=self.port) -class OpenVPNConnectionTest(unittest.TestCase): +class OpenVPNConnectionTest(BaseLeapTest): __name__ = "vpnconnection_tests" def setUp(self): - self.manager = MockedOpenVPNConnection() + # XXX this will have to change for win, host=localhost + host = eipconfig.get_socket_path() + self.manager = MockedOpenVPNConnection(host=host) def tearDown(self): - del self.manager - - # - # helpers - # - - # XXX hey, refactor this to basetestclass + # remove the socket folder. + # XXX only if posix. in win, host is localhost, so nothing + # has to be done. + if self.manager.host: + folder, fpath = os.path.split(self.manager.host) + assert folder.startswith('/tmp/leap-tmp') # safety check + shutil.rmtree(folder) - def _missing_test_for_plat(self, do_raise=False): - if do_raise: - raise NotImplementedError( - "This test is not implemented " - "for the running platform: %s" % - _system) + del self.manager # # tests @@ -78,7 +78,7 @@ class OpenVPNConnectionTest(unittest.TestCase): """ check default host for management iface """ - self.assertEqual(self.manager.host, '/tmp/.eip.sock') + self.assertTrue(self.manager.host.startswith('/tmp/leap-tmp')) self.assertEqual(self.manager.port, 'unix') @unittest.skipUnless(_system == "Windows", "win only") @@ -99,11 +99,6 @@ class OpenVPNConnectionTest(unittest.TestCase): self.manager = MockedOpenVPNConnection(port="bad") self.assertEqual(self.manager.port, None) - def test_connect_raises_missing_socket(self): - self.manager = openvpnconnection.OpenVPNConnection() - with self.assertRaises(eip_exceptions.MissingSocketError): - self.manager.connect_to_management() - def test_uds_telnet_called_on_connect(self): self.manager.connect_to_management() mock_UDSTelnet.assert_called_with( |