@@ -914,6 +914,63 @@ def test_sign_request(self):
914914 req .sign_request (oauth .SignatureMethod_HMAC_SHA1 (), con , tok )
915915 self .assertEquals (req ['oauth_signature' ], 'IBw5mfvoCsDjgpcsVKbyvsDqQaU=' )
916916
917+
918+ def test_from_request_works_with_wsgi (self ):
919+ """Make sure WSGI header HTTP_AUTHORIZATION is detected correctly."""
920+ url = "http://sp.example.com/"
921+
922+ params = {
923+ 'oauth_version' : "1.0" ,
924+ 'oauth_nonce' : "4572616e48616d6d65724c61686176" ,
925+ 'oauth_timestamp' : "137131200" ,
926+ 'oauth_consumer_key' : "0685bd9184jfhq22" ,
927+ 'oauth_signature_method' : "HMAC-SHA1" ,
928+ 'oauth_token' : "ad180jjd733klru7" ,
929+ 'oauth_signature' : "wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D" ,
930+ }
931+
932+ req = oauth .Request ("GET" , url , params )
933+ headers = req .to_header ()
934+
935+ # Munge the headers
936+ headers ['HTTP_AUTHORIZATION' ] = headers ['Authorization' ]
937+ del headers ['Authorization' ]
938+
939+ # Test from the headers
940+ req = oauth .Request .from_request ("GET" , url , headers )
941+ self .assertEquals (req .method , "GET" )
942+ self .assertEquals (req .url , url )
943+ self .assertEquals (params , req .copy ())
944+
945+
946+ def test_from_request_is_case_insensitive_checking_for_auth (self ):
947+ """Checks for the Authorization header should be case insensitive."""
948+ url = "http://sp.example.com/"
949+
950+ params = {
951+ 'oauth_version' : "1.0" ,
952+ 'oauth_nonce' : "4572616e48616d6d65724c61686176" ,
953+ 'oauth_timestamp' : "137131200" ,
954+ 'oauth_consumer_key' : "0685bd9184jfhq22" ,
955+ 'oauth_signature_method' : "HMAC-SHA1" ,
956+ 'oauth_token' : "ad180jjd733klru7" ,
957+ 'oauth_signature' : "wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D" ,
958+ }
959+
960+ req = oauth .Request ("GET" , url , params )
961+ headers = req .to_header ()
962+
963+ # Munge the headers
964+ headers ['authorization' ] = headers ['Authorization' ]
965+ del headers ['Authorization' ]
966+
967+ # Test from the headers
968+ req = oauth .Request .from_request ("GET" , url , headers )
969+ self .assertEquals (req .method , "GET" )
970+ self .assertEquals (req .url , url )
971+ self .assertEquals (params , req .copy ())
972+
973+
917974 def test_from_request (self ):
918975 url = "http://sp.example.com/"
919976
0 commit comments