diff options
author | Tomás Touceda <chiiph@leap.se> | 2013-06-28 13:18:15 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2013-06-28 13:18:15 -0300 |
commit | 4785877270da1702aa3a4a170a62baa494eb35fa (patch) | |
tree | 3109f1edc3a3648b37f9ccd93f9eb9e3db16e6a8 /src/leap | |
parent | 90c4d00b63edb379e5b0101ad870b528328247b1 (diff) | |
parent | 32b6afae6eb66cd75608b26aecd86bbfc587736e (diff) |
Merge remote-tracking branch 'ivan/bug/3032_supported-services-fix' into develop
Diffstat (limited to 'src/leap')
-rw-r--r-- | src/leap/config/providerconfig.py | 8 | ||||
-rw-r--r-- | src/leap/config/tests/test_providerconfig.py | 29 | ||||
-rw-r--r-- | src/leap/gui/wizard.py | 4 | ||||
-rw-r--r-- | src/leap/services/__init__.py | 6 |
4 files changed, 33 insertions, 14 deletions
diff --git a/src/leap/config/providerconfig.py b/src/leap/config/providerconfig.py index 94568c27..8b72153a 100644 --- a/src/leap/config/providerconfig.py +++ b/src/leap/config/providerconfig.py @@ -24,7 +24,6 @@ import os from leap.common.check import leap_assert from leap.common.config.baseconfig import BaseConfig, LocalizedKey from leap.config.provider_spec import leap_provider_spec -from leap.services import get_available logger = logging.getLogger(__name__) @@ -81,17 +80,16 @@ class ProviderConfig(BaseConfig): def get_services(self): """ - Returns a list with the services supported by the - current provider. + Returns a list with the available services in the current provider. :rtype: list """ - services = get_available(self._safe_get_value("services")) + services = self._safe_get_value("services") return services def get_services_string(self): """ - Returns a string with the services supported by the current + Returns a string with the available services in the current provider, ready to be shown to the user. """ services_str = ", ".join(self.get_services()) diff --git a/src/leap/config/tests/test_providerconfig.py b/src/leap/config/tests/test_providerconfig.py index 57688fb0..4e86a5f7 100644 --- a/src/leap/config/tests/test_providerconfig.py +++ b/src/leap/config/tests/test_providerconfig.py @@ -29,6 +29,7 @@ import copy from leap.common.testing.basetest import BaseLeapTest from leap.config.providerconfig import ProviderConfig +from leap.services import get_supported from mock import Mock @@ -235,8 +236,7 @@ class ProviderConfigTest(BaseLeapTest): config['services'] = ['mx', 'other_service'] json_string = json.dumps(config) pc.load(data=json_string) - # TODO: we do not support mx yet - self.assertFalse(pc.provides_mx()) + self.assertTrue(pc.provides_mx()) # It does not provides config['services'] = ['test_service', 'other_service'] @@ -244,14 +244,35 @@ class ProviderConfigTest(BaseLeapTest): pc.load(data=json_string) self.assertFalse(pc.provides_mx()) + def test_supports_unknown_service(self): + pc = self._provider_config + config = copy.deepcopy(sample_config) + + config['services'] = ['unknown'] + json_string = json.dumps(config) + pc.load(data=json_string) + self.assertFalse('unknown' in get_supported(pc.get_services())) + + def test_provides_unknown_service(self): + pc = self._provider_config + config = copy.deepcopy(sample_config) + + config['services'] = ['unknown'] + json_string = json.dumps(config) + pc.load(data=json_string) + self.assertTrue('unknown' in pc.get_services()) + def test_get_services_string(self): pc = self._provider_config config = copy.deepcopy(sample_config) - config['services'] = ['test01', 'test02'] + config['services'] = [ + 'openvpn', 'asdf', 'openvpn', 'not_supported_service'] json_string = json.dumps(config) pc.load(data=json_string) - self.assertEqual(pc.get_services_string(), "test01, test02") + self.assertEqual(pc.get_services_string(), + "Encrypted Internet, asdf, Encrypted Internet," + " not_supported_service") if __name__ == "__main__": diff --git a/src/leap/gui/wizard.py b/src/leap/gui/wizard.py index 34eba84c..b29250c8 100644 --- a/src/leap/gui/wizard.py +++ b/src/leap/gui/wizard.py @@ -33,7 +33,7 @@ from leap.util.privilege_policies import is_missing_policy_permissions from leap.util.request_helpers import get_content from leap.util.keyring_helpers import has_keyring from leap.services.eip.providerbootstrapper import ProviderBootstrapper -from leap.services import get_available +from leap.services import get_supported logger = logging.getLogger(__name__) @@ -523,7 +523,7 @@ class Wizard(QtGui.QWizard): self.tr("Services by %s") % (self._provider_config.get_name(),)) - services = get_available( + services = get_supported( self._provider_config.get_services()) for service in services: diff --git a/src/leap/services/__init__.py b/src/leap/services/__init__.py index 70a5dcf2..fc4aa416 100644 --- a/src/leap/services/__init__.py +++ b/src/leap/services/__init__.py @@ -17,10 +17,10 @@ """ Services module. """ -NOT_YET_DEPLOYED = ["mx"] # for 0.2.2 release +DEPLOYED = ["openvpn"] # for 0.2.2 release -def get_available(services): +def get_supported(services): """ Returns a list of the available services. @@ -30,4 +30,4 @@ def get_available(services): :returns: a list of the available services :rtype: list of str """ - return filter(lambda s: s not in NOT_YET_DEPLOYED, services) + return filter(lambda s: s in DEPLOYED, services) |