summaryrefslogtreecommitdiff
path: root/src/leap/base
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-08-29 23:05:38 +0900
committerkali <kali@leap.se>2012-08-29 23:05:38 +0900
commited4ad3a392caf0211e51a48d2d7b6c5a2f7bb17a (patch)
tree55958957a27f3784aef99f122673852becb4c1c2 /src/leap/base
parent63c0b7aa3ded55426a834d0a5947fff798894c6b (diff)
add eipconfig spec and config object
Diffstat (limited to 'src/leap/base')
-rw-r--r--src/leap/base/config.py3
-rw-r--r--src/leap/base/providers.py6
-rw-r--r--src/leap/base/tests/test_config.py25
3 files changed, 9 insertions, 25 deletions
diff --git a/src/leap/base/config.py b/src/leap/base/config.py
index 1ced471b..465016db 100644
--- a/src/leap/base/config.py
+++ b/src/leap/base/config.py
@@ -141,6 +141,9 @@ class JSONLeapConfig(BaseLeapConfig):
config_file = get_config_file(filename, folder)
return config_file
+ def exists(self):
+ return os.path.isfile(self.filename)
+
#
# utility functions
diff --git a/src/leap/base/providers.py b/src/leap/base/providers.py
index 71ccf139..677dd6ec 100644
--- a/src/leap/base/providers.py
+++ b/src/leap/base/providers.py
@@ -6,16 +6,16 @@ from leap.base import specs
class LeapProviderDefinition(baseconfig.JSONLeapConfig):
spec = specs.leap_provider_spec
- def get_slug(self):
+ def _get_slug(self):
provider_path = baseconfig.get_default_provider_path()
return baseconfig.get_config_file(
'definition.json',
folder=provider_path)
- def set_slug(self, *args, **kwargs):
+ def _set_slug(self, *args, **kwargs):
raise AttributeError("you cannot set slug")
- slug = property(get_slug, set_slug)
+ slug = property(_get_slug, _set_slug)
# TODO (MVS+)
# we will construct slug from providers/%s/definition.json
diff --git a/src/leap/base/tests/test_config.py b/src/leap/base/tests/test_config.py
index 54e4484c..ef897a23 100644
--- a/src/leap/base/tests/test_config.py
+++ b/src/leap/base/tests/test_config.py
@@ -35,7 +35,9 @@ class ProviderTest(BaseLeapTest):
class BareHomeTestCase(ProviderTest):
- __name__ = "provider_config_tests"
+ __name__ = "provider_config_tests_bare_home"
+
+ # XXX review. is it still needed?
def test_should_raise_if_missing_eip_json(self):
with self.assertRaises(exceptions.MissingConfigFileError):
@@ -59,27 +61,6 @@ class ProviderDefinitionTestCase(ProviderTest):
with open(os.path.join(path, 'eip.json'), 'w') as fp:
json.dump(eipconstants.EIP_SAMPLE_JSON, fp)
- # moved to eip.test_checks.test_fetch_definition
- #def test_complete_file(self):
- #with mock.patch.object(requests, "get") as mock_method:
- #mock_method.return_value.status_code = 200
- #mock_method.return_value.json = {
- #XXX get from providers template
- #u'api_uri': u'https://api.testprovider.org/',
- #u'api_version': u'0.1.0',
- #u'ca_cert': u'8aab80ae4326fd30721689db813733783fe0bd7e',
- #u'ca_cert_uri': u'https://testprovider.org/cacert.pem',
- #u'description': {u'en': u'This is a test provider'},
- #u'display_name': {u'en': u'Test Provider'},
- #u'domain': u'testprovider.org',
- #u'enrollment_policy': u'open',
- #u'public_key': u'cb7dbd679f911e85bc2e51bd44afd7308ee19c21',
- #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)
#
# provider fetch tests block