Merge lp:~bloodearnest/canonical-identity-provider/ssoclient into lp:~canonical-isd-hackers/canonical-identity-provider/ssoclient

Proposed by Simon Davy
Status: Merged
Approved by: Michael Foord
Approved revision: no longer in the source branch.
Merged at revision: 4
Proposed branch: lp:~bloodearnest/canonical-identity-provider/ssoclient
Merge into: lp:~canonical-isd-hackers/canonical-identity-provider/ssoclient
Diff against target: 61 lines (+23/-12)
2 files modified
ssoclient/tests/test_v2.py (+9/-0)
ssoclient/v2/client.py (+14/-12)
To merge this branch: bzr merge lp:~bloodearnest/canonical-identity-provider/ssoclient
Reviewer Review Type Date Requested Status
Michael Foord (community) Approve
Review via email: mp+152462@code.launchpad.net

Commit message

added support for anonymous requests for account_details

Description of the change

added support for anonymous requests for account_details

To post a comment you must log in.
Revision history for this message
Michael Foord (mfoord) wrote :

LGTM

review: Approve
4. By Simon Davy

[r=mfoord] added support for anonymous requests for account_details

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ssoclient/tests/test_v2.py'
2--- ssoclient/tests/test_v2.py 2013-02-19 13:36:06 +0000
3+++ ssoclient/tests/test_v2.py 2013-03-08 17:15:32 +0000
4@@ -239,6 +239,15 @@
5 # repsonse
6 self.assertEqual(response.status_code, 200)
7
8+ @patch(REQUEST, return_value=mock_response(200))
9+ def test_account_details_anonymous(self, mock_request):
10+ response = self.client.account_details('some_openid')
11+ mock_request.assert_called_once_with(
12+ 'GET', 'http://foo.com/accounts/some_openid', auth=None,
13+ headers={}, allow_redirects=True,
14+ )
15+ self.assertEqual(response.status_code, 200)
16+
17
18 class ValidateRequestV2ClientApiTestCase(V2ClientApiTestCase):
19
20
21=== modified file 'ssoclient/v2/client.py'
22--- ssoclient/v2/client.py 2013-02-18 20:23:28 +0000
23+++ ssoclient/v2/client.py 2013-03-08 17:15:32 +0000
24@@ -37,23 +37,25 @@
25
26 @api_exception(errors.InvalidCredentials)
27 @api_exception(errors.ResourceNotFound)
28- def account_details(self, openid, token):
29+ def account_details(self, openid, token=None):
30 # if openid and token come directly from a call to client.login
31 # then whether they are unicode or byte-strings depends on which
32 # json library is in use.
33 # oauthlib requires them to be unicode - so we coerce to be sure.
34 openid = unicode(openid)
35- consumer_key = unicode(token['consumer_key'])
36- consumer_secret = unicode(token['consumer_secret'])
37- token_key = unicode(token['token_key'])
38- token_secret = unicode(token['token_secret'])
39- oauth = OAuth1(
40- consumer_key,
41- consumer_secret,
42- token_key, token_secret,
43- )
44- return self.session.get(
45- '/accounts/%s' % openid, auth=oauth)
46+ if token is not None:
47+ consumer_key = unicode(token['consumer_key'])
48+ consumer_secret = unicode(token['consumer_secret'])
49+ token_key = unicode(token['token_key'])
50+ token_secret = unicode(token['token_secret'])
51+ oauth = OAuth1(
52+ consumer_key,
53+ consumer_secret,
54+ token_key, token_secret,
55+ )
56+ else:
57+ oauth = None
58+ return self.session.get('/accounts/%s' % openid, auth=oauth)
59
60 def validate_request(self, data=None, **kwargs):
61 return self.session.post('/requests/validate',

Subscribers

People subscribed via source and target branches