summaryrefslogtreecommitdiff
path: root/src/leap/eip/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/eip/tests')
-rw-r--r--src/leap/eip/tests/test_config.py43
-rw-r--r--src/leap/eip/tests/test_eipconnection.py21
2 files changed, 26 insertions, 38 deletions
diff --git a/src/leap/eip/tests/test_config.py b/src/leap/eip/tests/test_config.py
index 87ef33ef..c73281cc 100644
--- a/src/leap/eip/tests/test_config.py
+++ b/src/leap/eip/tests/test_config.py
@@ -1,15 +1,16 @@
-import ConfigParser
import os
import platform
+import stat
try:
import unittest2 as unittest
except ImportError:
import unittest
-from leap.base import constants
-from leap.eip import config as eip_config
+#from leap.base import constants
+#from leap.eip import config as eip_config
from leap.testing.basetest import BaseLeapTest
+from leap.util.fileutil import mkdir_p
_system = platform.system()
@@ -29,19 +30,14 @@ class EIPConfigTest(BaseLeapTest):
#
def touch_exec(self):
+ path = os.path.join(
+ self.tempdir, 'bin')
+ mkdir_p(path)
tfile = os.path.join(
- self.tempfile,
- 'bin',
+ path,
'openvpn')
- open(tfile, 'bw').close()
-
- def get_empty_config(self):
- _config = ConfigParser.ConfigParser()
- return _config
-
- def get_minimal_config(self):
- _config = ConfigParser.ConfigParser()
- return _config
+ open(tfile, 'wb').close()
+ os.chmod(tfile, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
def get_expected_openvpn_args(self):
args = []
@@ -110,17 +106,18 @@ class EIPConfigTest(BaseLeapTest):
# some checks.
def test_build_ovpn_command_empty_config(self):
- _config = self.get_empty_config()
- command, args = eip_config.build_ovpn_command(
- _config,
- do_pkexec_check=False)
- self.assertEqual(command, 'openvpn')
+ self.touch_exec()
+ from leap.eip import config as eipconfig
+ from leap.util.fileutil import which
+ path = os.environ['PATH']
+ vpnbin = which('openvpn', path=path)
+ print 'path =', path
+ print 'vpnbin = ', vpnbin
+ command, args = eipconfig.build_ovpn_command(
+ do_pkexec_check=False, vpnbin=vpnbin)
+ self.assertEqual(command, self.home + '/bin/openvpn')
self.assertEqual(args, self.get_expected_openvpn_args())
- # XXX TODO:
- # - should use touch_exec to plant an "executable" in the path
- # - should check that "which" for openvpn returns what's expected.
-
if __name__ == "__main__":
unittest.main()
diff --git a/src/leap/eip/tests/test_eipconnection.py b/src/leap/eip/tests/test_eipconnection.py
index 26f6529e..23f645c3 100644
--- a/src/leap/eip/tests/test_eipconnection.py
+++ b/src/leap/eip/tests/test_eipconnection.py
@@ -1,4 +1,3 @@
-import ConfigParser
import logging
import platform
import os
@@ -13,9 +12,9 @@ except ImportError:
from mock import Mock, patch # MagicMock
-from leap.base import constants
from leap.eip.eipconnection import EIPConnection
from leap.eip.exceptions import ConnectionRefusedError
+from leap.eip import specs as eipspecs
from leap.testing.basetest import BaseLeapTest
_system = platform.system()
@@ -29,7 +28,6 @@ class NotImplementedError(Exception):
@patch('OpenVPNConnection._set_ovpn_command')
class MockedEIPConnection(EIPConnection):
def _get_or_create_config(self):
- self.config = ConfigParser.ConfigParser()
self._set_ovpn_command()
def _set_ovpn_command(self):
@@ -56,11 +54,11 @@ class EIPConductorTest(BaseLeapTest):
# XXX change to keys_checker invocation
# (see config_checker)
- filepath = os.path.expanduser(
- '~/.config/leap/providers/%s/openvpn.keys'
- % constants.DEFAULT_TEST_PROVIDER)
- self.touch(filepath)
- self.chmod600(filepath)
+ keyfiles = (eipspecs.provider_ca_path(),
+ eipspecs.client_cert_path())
+ for filepath in keyfiles:
+ self.touch(filepath)
+ self.chmod600(filepath)
# we init the manager with only
# some methods mocked
@@ -85,13 +83,6 @@ class EIPConductorTest(BaseLeapTest):
self.assertEqual(con.missing_provider, False)
self.assertEqual(con.bad_provider, False)
- def test_config_was_init(self):
- """
- is there a config object?
- """
- self.assertTrue(isinstance(self.con.config,
- ConfigParser.ConfigParser))
-
def test_ovpn_command(self):
"""
set_ovpn_command called