File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 29
29
import hmac
30
30
import binascii
31
31
import httplib2
32
+ from types import ListType
32
33
33
34
try :
34
35
from urlparse import parse_qs , parse_qsl
@@ -327,8 +328,9 @@ def get_parameter(self, parameter):
327
328
328
329
def get_normalized_parameters (self ):
329
330
"""Return a string that contains the parameters that must be signed."""
330
- items = [(k , v ) for k , v in self .items () if k != 'oauth_signature' ]
331
- encoded_str = urllib .urlencode (sorted (items ), True )
331
+ # 1.0a/9.1.1 states that kvp must be sorted by key, then by value
332
+ items = [(k , v if type (v ) != ListType else sorted (v )) for k ,v in sorted (self .items ()) if k != 'oauth_signature' ]
333
+ encoded_str = urllib .urlencode (items , True )
332
334
# Encode signature parameters per Oauth Core 1.0 protocol
333
335
# spec draft 7, section 3.6
334
336
# (http://tools.ietf.org/html/draft-hammer-oauth-07#section-3.6)
Original file line number Diff line number Diff line change 30
30
import time
31
31
import urllib
32
32
import urlparse
33
+ from types import ListType
33
34
34
35
35
36
# Fix for python2.5 compatibility
@@ -372,13 +373,16 @@ def test_get_normalized_parameters(self):
372
373
'oauth_consumer_key' : "0685bd9184jfhq22" ,
373
374
'oauth_signature_method' : "HMAC-SHA1" ,
374
375
'oauth_token' : "ad180jjd733klru7" ,
376
+ 'multi' : ['FOO' ,'BAR' ],
375
377
}
376
378
377
379
req = oauth .Request ("GET" , url , params )
378
380
379
381
res = req .get_normalized_parameters ()
382
+
383
+ srtd = [(k , v if type (v ) != ListType else sorted (v )) for k ,v in sorted (params .items ())]
380
384
381
- self .assertEquals (urllib .urlencode (sorted ( params . items ()) ), res )
385
+ self .assertEquals (urllib .urlencode (srtd , True ), res )
382
386
383
387
def test_get_normalized_parameters_ignores_auth_signature (self ):
384
388
url = "http://sp.example.com/"
You can’t perform that action at this time.
0 commit comments