summaryrefslogtreecommitdiff
path: root/src/leap/eip/tests/test_checks.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/eip/tests/test_checks.py')
-rw-r--r--src/leap/eip/tests/test_checks.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/leap/eip/tests/test_checks.py b/src/leap/eip/tests/test_checks.py
index 19b54c04..582dcb84 100644
--- a/src/leap/eip/tests/test_checks.py
+++ b/src/leap/eip/tests/test_checks.py
@@ -12,6 +12,7 @@ import urlparse
from StringIO import StringIO
from mock import (patch, Mock)
+import jsonschema
import ping
import requests
@@ -149,12 +150,12 @@ class EIPCheckTest(BaseLeapTest):
# force re-evaluation of the paths
# small workaround for evaluating home dirs correctly
- EIP_SAMPLE_JSON = copy.copy(testdata.EIP_SAMPLE_JSON)
- EIP_SAMPLE_JSON['openvpn_client_certificate'] = \
+ EIP_SAMPLE_CONFIG = copy.copy(testdata.EIP_SAMPLE_CONFIG)
+ EIP_SAMPLE_CONFIG['openvpn_client_certificate'] = \
eipspecs.client_cert_path()
- EIP_SAMPLE_JSON['openvpn_ca_certificate'] = \
+ EIP_SAMPLE_CONFIG['openvpn_ca_certificate'] = \
eipspecs.provider_ca_path()
- self.assertEqual(deserialized, EIP_SAMPLE_JSON)
+ self.assertEqual(deserialized, EIP_SAMPLE_CONFIG)
# TODO: shold ALSO run validation methods.
@@ -171,16 +172,20 @@ class EIPCheckTest(BaseLeapTest):
# ok. now, messing with real files...
# blank out default_provider
- sampleconfig = copy.copy(testdata.EIP_SAMPLE_JSON)
+ sampleconfig = copy.copy(testdata.EIP_SAMPLE_CONFIG)
sampleconfig['provider'] = None
eipcfg_path = checker.eipconfig.filename
with open(eipcfg_path, 'w') as fp:
json.dump(sampleconfig, fp)
- with self.assertRaises(eipexceptions.EIPMissingDefaultProvider):
+ #with self.assertRaises(eipexceptions.EIPMissingDefaultProvider):
+ # XXX we should catch this as one of our errors, but do not
+ # see how to do it quickly.
+ with self.assertRaises(jsonschema.ValidationError):
+ #import ipdb;ipdb.set_trace()
checker.eipconfig.load(fromfile=eipcfg_path)
checker.check_is_there_default_provider()
- sampleconfig = testdata.EIP_SAMPLE_JSON
+ sampleconfig = testdata.EIP_SAMPLE_CONFIG
#eipcfg_path = checker._get_default_eipconfig_path()
with open(eipcfg_path, 'w') as fp:
json.dump(sampleconfig, fp)
@@ -192,7 +197,7 @@ class EIPCheckTest(BaseLeapTest):
mocked_get.return_value.status_code = 200
mocked_get.return_value.json = DEFAULT_PROVIDER_DEFINITION
checker = eipchecks.EIPConfigChecker(fetcher=requests)
- sampleconfig = testdata.EIP_SAMPLE_JSON
+ sampleconfig = testdata.EIP_SAMPLE_CONFIG
checker.fetch_definition(config=sampleconfig)
fn = os.path.join(baseconfig.get_default_provider_path(),
@@ -210,22 +215,22 @@ class EIPCheckTest(BaseLeapTest):
mocked_get.return_value.status_code = 200
mocked_get.return_value.json = testdata.EIP_SAMPLE_SERVICE
checker = eipchecks.EIPConfigChecker(fetcher=requests)
- sampleconfig = testdata.EIP_SAMPLE_JSON
+ sampleconfig = testdata.EIP_SAMPLE_CONFIG
checker.fetch_eip_service_config(config=sampleconfig)
def test_check_complete_eip_config(self):
checker = eipchecks.EIPConfigChecker()
with self.assertRaises(eipexceptions.EIPConfigurationError):
- sampleconfig = copy.copy(testdata.EIP_SAMPLE_JSON)
+ sampleconfig = copy.copy(testdata.EIP_SAMPLE_CONFIG)
sampleconfig['provider'] = None
checker.check_complete_eip_config(config=sampleconfig)
with self.assertRaises(eipexceptions.EIPConfigurationError):
- sampleconfig = copy.copy(testdata.EIP_SAMPLE_JSON)
+ sampleconfig = copy.copy(testdata.EIP_SAMPLE_CONFIG)
del sampleconfig['provider']
checker.check_complete_eip_config(config=sampleconfig)
# normal case
- sampleconfig = copy.copy(testdata.EIP_SAMPLE_JSON)
+ sampleconfig = copy.copy(testdata.EIP_SAMPLE_CONFIG)
checker.check_complete_eip_config(config=sampleconfig)