From 4a46723219e5284bec21b9dccd6589a670babc63 Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 27 Aug 2012 23:21:43 +0900 Subject: add test_dump_default_eipconfig to eip.test_checks plus a little bit of cleaning around (created constants file). added some notes about inminent deprecation *work in progress* --- src/leap/base/config.py | 3 ++- src/leap/base/tests/test_config.py | 25 +++++++------------------ 2 files changed, 9 insertions(+), 19 deletions(-) (limited to 'src/leap/base') diff --git a/src/leap/base/config.py b/src/leap/base/config.py index 4d7db018..93a89638 100644 --- a/src/leap/base/config.py +++ b/src/leap/base/config.py @@ -162,7 +162,7 @@ def get_groupname(): # json stuff -# XXX merge with JSONConfig +# XXX merge with JSONConfig / EIPChecks as appropiate. def get_config_json(config_file=None): """ will replace get_config function be developing them @@ -236,6 +236,7 @@ class Configuration(object): except requests.ConnectionError as e: if e.message == "[Errno 113] No route to host": if not is_internet_up: + # this was meant to be a function invocation I guess... self.error = "No valid internet connection found" else: self.error = "Provider server appears currently down." diff --git a/src/leap/base/tests/test_config.py b/src/leap/base/tests/test_config.py index 67be0e54..93de0782 100644 --- a/src/leap/base/tests/test_config.py +++ b/src/leap/base/tests/test_config.py @@ -10,6 +10,7 @@ import requests from leap.base import config from leap.base import constants from leap.base import exceptions +from leap.eip import constants as eipconstants from leap.util.fileutil import mkdir_p from leap.testing.basetest import BaseLeapTest @@ -50,26 +51,13 @@ class ProviderDefinitionTestCase(ProviderTest): def setUp(self): # dump a sample eip file # XXX Move to Use EIP Spec Instead!!! - EIP_JSON = { - "provider": "testprovider.org", - "transport": "openvpn", - "openvpn_protocol": "tcp", - "openvpn_port": "80", - "openvpn_ca_certificate": "~/.config/leap/testprovider.org/" - "keys/ca/testprovider-ca-cert-" - "2013-01-01.pem", - "openvpn_client_certificate": "~/.config/leap/testprovider.org/" - "keys/client/openvpn-2012-09-31.pem", - "connect_on_login": True, - "block_cleartext_traffic": True, - "primary_gateway": "usa_west", - "secondary_gateway": "france", - "management_password": "oph7Que1othahwiech6J" - } + # XXX tests to be moved to eip.checks and eip.providers + # XXX can use eipconfig.dump_default_eipconfig + path = os.path.join(self.home, '.config', 'leap') mkdir_p(path) with open(os.path.join(path, 'eip.json'), 'w') as fp: - json.dump(EIP_JSON, fp) + json.dump(eipconstants.EIP_SAMPLE_JSON, fp) def test_complete_file(self): with mock.patch.object(requests, "get") as mock_method: @@ -88,6 +76,7 @@ class ProviderDefinitionTestCase(ProviderTest): u'serial': 1, u'services': [u'eip'], u'version': u'0.1.0'} + # XXX why init to localhost? cf = config.Configuration("http://localhost/") self.assertIn('default', cf.providers) @@ -238,7 +227,7 @@ class ConfigHelperFunctions(BaseLeapTest): """ code to be written yet """ - pass + raise NotImplementedError if __name__ == "__main__": -- cgit v1.2.3