summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/leap/services/mail/smtpspec.py2
-rw-r--r--src/leap/services/soledad/soledadbootstrapper.py6
-rw-r--r--src/leap/services/soledad/soledadconfig.py10
-rw-r--r--src/leap/services/soledad/soledadspec.py21
4 files changed, 32 insertions, 7 deletions
diff --git a/src/leap/services/mail/smtpspec.py b/src/leap/services/mail/smtpspec.py
index 9fc1984a..ff9d1bf8 100644
--- a/src/leap/services/mail/smtpspec.py
+++ b/src/leap/services/mail/smtpspec.py
@@ -19,7 +19,7 @@
# To add a schema for a version you should follow the form:
# { '1': schema_v1, '2': schema_v2, ... etc }
# so for instance, to add the '2' version, you should do:
-# eipservice_config_spec['2'] = schema_v2
+# smtp_config_spec['2'] = schema_v2
smtp_config_spec = {}
smtp_config_spec['1'] = {
diff --git a/src/leap/services/soledad/soledadbootstrapper.py b/src/leap/services/soledad/soledadbootstrapper.py
index d53aeadb..7ac4203b 100644
--- a/src/leap/services/soledad/soledadbootstrapper.py
+++ b/src/leap/services/soledad/soledadbootstrapper.py
@@ -143,10 +143,12 @@ class SoledadBootstrapper(AbstractBootstrapper):
if self._download_if_needed and mtime:
headers['if-modified-since'] = mtime
+ api_version = self._provider_config.get_api_version()
+
# there is some confusion with this uri,
config_uri = "%s/%s/config/soledad-service.json" % (
self._provider_config.get_api_uri(),
- self._provider_config.get_api_version())
+ api_version)
logger.debug('Downloading soledad config from: %s' % config_uri)
srp_auth = SRPAuth(self._provider_config)
@@ -162,6 +164,8 @@ class SoledadBootstrapper(AbstractBootstrapper):
cookies=cookies)
res.raise_for_status()
+ self._soledad_config.set_api_version(api_version)
+
# Not modified
if res.status_code == 304:
logger.debug("Soledad definition has not been modified")
diff --git a/src/leap/services/soledad/soledadconfig.py b/src/leap/services/soledad/soledadconfig.py
index 80a82d11..a2367692 100644
--- a/src/leap/services/soledad/soledadconfig.py
+++ b/src/leap/services/soledad/soledadconfig.py
@@ -21,7 +21,7 @@ Soledad configuration
import logging
from leap.common.config.baseconfig import BaseConfig
-from leap.services.soledad.soledadspec import soledad_config_spec
+from leap.services.soledad.soledadspec import get_schema
logger = logging.getLogger(__name__)
@@ -34,11 +34,13 @@ class SoledadConfig(BaseConfig):
def __init__(self):
BaseConfig.__init__(self)
- def _get_spec(self):
+ def _get_schema(self):
"""
- Returns the spec object for the specific configuration
+ Returns the schema corresponding to the version given.
+
+ :rtype: dict or None if the version is not supported.
"""
- return soledad_config_spec
+ return get_schema(self._api_version)
def get_hosts(self):
return self._safe_get_value("hosts")
diff --git a/src/leap/services/soledad/soledadspec.py b/src/leap/services/soledad/soledadspec.py
index 8233d6a0..111175dd 100644
--- a/src/leap/services/soledad/soledadspec.py
+++ b/src/leap/services/soledad/soledadspec.py
@@ -15,7 +15,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-soledad_config_spec = {
+# Schemas dict
+# To add a schema for a version you should follow the form:
+# { '1': schema_v1, '2': schema_v2, ... etc }
+# so for instance, to add the '2' version, you should do:
+# soledad_config_spec['2'] = schema_v2
+soledad_config_spec = {}
+
+soledad_config_spec['1'] = {
'description': 'sample soledad service config',
'type': 'object',
'properties': {
@@ -55,3 +62,15 @@ soledad_config_spec = {
}
}
}
+
+
+def get_schema(version):
+ """
+ Returns the schema corresponding to the version given.
+
+ :param version: the version of the schema to get.
+ :type version: str
+ :rtype: dict or None if the version is not supported.
+ """
+ schema = soledad_config_spec.get(version, None)
+ return schema