blob: 3c5a1cde6c32c4f42457bbe0a4f83f8afe3895e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
import ConfigParser
import os
import platform
import socket
try:
import unittest2 as unittest
except ImportError:
import unittest
from leap.testing.basetest import BaseLeapTest
from leap.base import config as base_config
from leap.eip import config as eip_config
_system = platform.system()
class EIPConfigTest(BaseLeapTest):
__name__ = "eip_config_tests"
def setUp(self):
pass
def tearDown(self):
pass
#
# helpers
#
def touch_exec(self):
tfile = os.path.join(
self.tempfile,
'bin',
'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
def get_expected_openvpn_args(self):
args = []
username = self.get_username()
groupname = self.get_groupname()
args.append('--user')
args.append(username)
args.append('--group')
args.append(groupname)
args.append('--management-client-user')
args.append(username)
args.append('--management-signal')
args.append('--management')
#XXX hey!
#get platform switches here!
args.append('/tmp/.eip.sock')
args.append('unix')
args.append('--config')
#XXX bad assumption. FIXME: expand $HOME
args.append('/home/%s/.config/leap/providers/default/openvpn.conf' %
username)
return args
# build command string
# these tests are going to have to check
# many combinations. we should inject some
# params in the function call, to disable
# 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.assertEqual(args, self.get_expected_openvpn_args())
if __name__ == "__main__":
unittest.main()
|