Merge lp:~mandel/ubuntu-sso-client/parse-empty into lp:ubuntu-sso-client

Proposed by Manuel de la Peña
Status: Merged
Approved by: dobey
Approved revision: 941
Merged at revision: 940
Proposed branch: lp:~mandel/ubuntu-sso-client/parse-empty
Merge into: lp:ubuntu-sso-client
Diff against target: 60 lines (+31/-1)
2 files modified
ubuntu_sso/utils/webclient/gsettings.py (+8/-1)
ubuntu_sso/utils/webclient/tests/test_gsettings.py (+23/-0)
To merge this branch: bzr merge lp:~mandel/ubuntu-sso-client/parse-empty
Reviewer Review Type Date Requested Status
dobey (community) Approve
Eric Casteleijn (community) Approve
Review via email: mp+100392@code.launchpad.net

Commit message

- Fixed the issue where we use an empty proxy url when the proxy was not set in gsettings (LP: #969280).

Description of the change

- Fixed the issue where we use an empty proxy url when the proxy was not set in gsettings (LP: #969280).

To post a comment you must log in.
Revision history for this message
Eric Casteleijn (thisfred) wrote :

In general I prefer to use exceptions rather than signal values like None, but I assume there are other reasons to not to it that way. +1

review: Approve
Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ubuntu_sso/utils/webclient/gsettings.py'
--- ubuntu_sso/utils/webclient/gsettings.py 2012-03-07 15:12:39 +0000
+++ ubuntu_sso/utils/webclient/gsettings.py 2012-04-02 11:47:26 +0000
@@ -34,6 +34,11 @@
34def parse_manual_proxy_settings(scheme, gsettings):34def parse_manual_proxy_settings(scheme, gsettings):
35 """Parse the settings for a given scheme."""35 """Parse the settings for a given scheme."""
36 host, username, pwd = parse_proxy_host(gsettings[scheme + ".host"])36 host, username, pwd = parse_proxy_host(gsettings[scheme + ".host"])
37 # if the user did not set a proxy for a type (http/https/ftp) we should
38 # return None to ensure that it is not used
39 if host == '':
40 return None
41
37 settings = {42 settings = {
38 "host": host,43 "host": host,
39 "port": gsettings[scheme + ".port"],44 "port": gsettings[scheme + ".port"],
@@ -76,7 +81,9 @@
76 elif mode == "manual":81 elif mode == "manual":
77 settings = {}82 settings = {}
78 for scheme in ["http", "https"]:83 for scheme in ["http", "https"]:
79 settings[scheme] = parse_manual_proxy_settings(scheme, gsettings)84 scheme_settings = parse_manual_proxy_settings(scheme, gsettings)
85 if scheme_settings is not None:
86 settings[scheme] = scheme_settings
80 else:87 else:
81 # If mode is automatic the PAC javascript should be interpreted88 # If mode is automatic the PAC javascript should be interpreted
82 # on each request. That is out of scope so it's ignored for now89 # on each request. That is out of scope so it's ignored for now
8390
=== modified file 'ubuntu_sso/utils/webclient/tests/test_gsettings.py'
--- ubuntu_sso/utils/webclient/tests/test_gsettings.py 2012-03-09 12:04:31 +0000
+++ ubuntu_sso/utils/webclient/tests/test_gsettings.py 2012-04-02 11:47:26 +0000
@@ -169,6 +169,29 @@
169 ps = gsettings.get_proxy_settings()169 ps = gsettings.get_proxy_settings()
170 self.assertEqual(ps["http"], http_expected)170 self.assertEqual(ps["http"], http_expected)
171171
172 def _assert_parser_empty_url(self, scheme):
173 """Assert the parsing of an empty url."""
174 template_values = dict(BASE_GSETTINGS_VALUES)
175 template_values.update({
176 "mode": "manual",
177 scheme + "_host": '',
178 scheme + "_port": 0,
179 "http_use_auth": "false",
180 })
181 fake_output = TEMPLATE_GSETTINGS_OUTPUT.format(**template_values)
182 self.patch(gsettings.subprocess, "check_output",
183 lambda _: fake_output)
184 ps = gsettings.get_proxy_settings()
185 self.assertNotIn(scheme, ps)
186
187 def test_gsettings_parser_empty_http_url(self):
188 """Test when there is no http proxy set."""
189 self._assert_parser_empty_url('http')
190
191 def test_gsettings_parser_empty_https_url(self):
192 """Test when there is no https proxy set."""
193 self._assert_parser_empty_url('https')
194
172195
173class ParseProxyHostTestCase(TestCase):196class ParseProxyHostTestCase(TestCase):
174 """Test the parsing of the domain."""197 """Test the parsing of the domain."""

Subscribers

People subscribed via source and target branches