From 8ff98b63c077af25fb58dc73750e7765c35ce2f0 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Fri, 28 Jun 2013 10:59:56 -0300 Subject: Bugfix: Update available/supported implementation. Closes bug #3032. --- src/leap/config/providerconfig.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/leap/config') 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()) -- cgit v1.2.3 From 32b6afae6eb66cd75608b26aecd86bbfc587736e Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Fri, 28 Jun 2013 11:05:59 -0300 Subject: Update and add tests for the api changes --- src/leap/config/tests/test_providerconfig.py | 29 ++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'src/leap/config') 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__": -- cgit v1.2.3