diff options
Diffstat (limited to 'src/leap/eip/test_config.py')
-rw-r--r-- | src/leap/eip/test_config.py | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/src/leap/eip/test_config.py b/src/leap/eip/test_config.py index d92ace9..12679ec 100644 --- a/src/leap/eip/test_config.py +++ b/src/leap/eip/test_config.py @@ -1,3 +1,4 @@ +import ConfigParser import os import platform import shutil @@ -43,9 +44,11 @@ class EIPConfigTest(unittest.TestCase): # def get_username(self): - return os.getlogin() + return config.get_username() + + def get_groupname(self): + return config.get_groupname() - #@unittest.skip def _missing_test_for_plat(self, do_raise=False): if do_raise: raise NotImplementedError( @@ -60,6 +63,38 @@ class EIPConfigTest(unittest.TestCase): '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 + # # tests # @@ -148,6 +183,28 @@ class EIPConfigTest(unittest.TestCase): with self.assertRaises(socket.error): config.validate_ip('foobar') + @unittest.skip + def test_validate_domain(self): + """ + code to be written yet + """ + pass + + # 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. + # XXX breaking! + + def test_build_ovpn_command_empty_config(self): + _config = self.get_empty_config() + command, args = 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() |