Merge lp:~alecu/ubuntu-sso-client/fix-wrong-credentials into lp:ubuntu-sso-client

Proposed by Alejandro J. Cura
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 921
Merged at revision: 922
Proposed branch: lp:~alecu/ubuntu-sso-client/fix-wrong-credentials
Merge into: lp:ubuntu-sso-client
Diff against target: 45 lines (+15/-4)
2 files modified
ubuntu_sso/utils/webclient/qtnetwork.py (+4/-2)
ubuntu_sso/utils/webclient/tests/test_webclient.py (+11/-2)
To merge this branch: bzr merge lp:~alecu/ubuntu-sso-client/fix-wrong-credentials
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+97989@code.launchpad.net

Commit message

- Handle wrong credentials properly in qtnetwork webclient (LP: #957317)

Description of the change

- Handle wrong credentials properly in qtnetwork webclient (LP: #957317)

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) wrote :

+5

review: Approve
Revision history for this message
Manuel de la Peña (mandel) wrote :

Wow, that was simple! I have done an IRL with this branch giving the wrong creds and worked. Nice!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/utils/webclient/qtnetwork.py'
2--- ubuntu_sso/utils/webclient/qtnetwork.py 2012-03-09 12:04:31 +0000
3+++ ubuntu_sso/utils/webclient/qtnetwork.py 2012-03-16 21:06:17 +0000
4@@ -188,8 +188,10 @@
5
6 def _handle_authentication(self, reply, authenticator):
7 """The reply needs authentication."""
8- authenticator.setUser(self.username)
9- authenticator.setPassword(self.password)
10+ if authenticator.user() != self.username:
11+ authenticator.setUser(self.username)
12+ if authenticator.password() != self.password:
13+ authenticator.setPassword(self.password)
14
15 @defer.inlineCallbacks
16 def _handle_bad_proxy_authentication(self, proxy, authenticator):
17
18=== modified file 'ubuntu_sso/utils/webclient/tests/test_webclient.py'
19--- ubuntu_sso/utils/webclient/tests/test_webclient.py 2012-03-12 23:15:45 +0000
20+++ ubuntu_sso/utils/webclient/tests/test_webclient.py 2012-03-16 21:06:17 +0000
21@@ -318,13 +318,22 @@
22 @defer.inlineCallbacks
23 def test_send_basic_auth(self):
24 """The basic authentication headers are sent."""
25- other_wc = webclient.webclient_factory(username=SAMPLE_USERNAME,
26- password=SAMPLE_PASSWORD)
27+ other_wc = self.webclient_factory(username=SAMPLE_USERNAME,
28+ password=SAMPLE_PASSWORD)
29 self.addCleanup(other_wc.shutdown)
30 result = yield other_wc.request(self.base_iri + GUARDED)
31 self.assertEqual(SAMPLE_RESOURCE, result.content)
32
33 @defer.inlineCallbacks
34+ def test_send_basic_auth_wrong_credentials(self):
35+ """Wrong credentials returns a webclient error."""
36+ other_wc = self.webclient_factory(username=SAMPLE_USERNAME,
37+ password="wrong password!")
38+ self.addCleanup(other_wc.shutdown)
39+ yield self.assertFailure(other_wc.request(self.base_iri + GUARDED),
40+ webclient.UnauthorizedError)
41+
42+ @defer.inlineCallbacks
43 def test_request_is_oauth_signed(self):
44 """The request is oauth signed."""
45 tsc = self.wc.get_timestamp_checker()

Subscribers

People subscribed via source and target branches