forked from oauthlib/oauthlib
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request oauthlib#20 from calebbrown/master
Bug fixes for the OAuth 1.0 Client and Server
- Loading branch information
Showing
6 changed files
with
90 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ Idan Gazit | |
David Gouldin | ||
Ib Lundgren | ||
Daniel Greenfeld | ||
Caleb Brown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from __future__ import absolute_import | ||
from oauthlib.oauth1.rfc5849 import * | ||
from oauthlib.oauth1.rfc5849 import utils | ||
from ...unittest import TestCase | ||
|
||
|
||
|
||
|
||
class ServerTests(TestCase): | ||
|
||
CLIENT_KEY = u'dpf43f3p2l4k3l03' | ||
CLIENT_SECRET = u'kd94hf93k423kf44' | ||
|
||
RESOURCE_OWNER_KEY = u'kkk9d7dh3k39sjv7' | ||
RESOURCE_OWNER_SECRET = u'just-a-string asdasd' | ||
|
||
class TestServer(Server): | ||
def get_client_secret(self, client_key): | ||
return ServerTests.CLIENT_SECRET | ||
|
||
def get_resource_owner_secret(self, resource_owner_key): | ||
return ServerTests.RESOURCE_OWNER_SECRET | ||
|
||
def check_client_key(self, client_key): | ||
return ServerTests.CLIENT_KEY == client_key | ||
|
||
def check_resource_owner_key(self, client_key, resource_owner_key): | ||
return (ServerTests.CLIENT_KEY == client_key and | ||
ServerTests.RESOURCE_OWNER_KEY == resource_owner_key) | ||
|
||
def check_timestamp_and_nonce(self, timestamp, nonce): | ||
return True | ||
|
||
def test_basic_server_request(self): | ||
c = Client(self.CLIENT_KEY, | ||
client_secret=self.CLIENT_SECRET, | ||
resource_owner_key=self.RESOURCE_OWNER_KEY, | ||
resource_owner_secret=self.RESOURCE_OWNER_SECRET, | ||
) | ||
|
||
uri, body, headers = c.sign(u'http://server.example.com:80/init') | ||
|
||
headers = dict([(str(k), str(v)) for k, v in headers.iteritems()]) | ||
|
||
s = self.TestServer() | ||
self.assertTrue(s.check_request_signature(uri, body=body, | ||
headers=headers)) | ||
|
||
def test_server_callback_request(self): | ||
c = Client(self.CLIENT_KEY, | ||
client_secret=self.CLIENT_SECRET, | ||
resource_owner_key=self.RESOURCE_OWNER_KEY, | ||
resource_owner_secret=self.RESOURCE_OWNER_SECRET, | ||
callback_uri=u'http://client.example.com/callback' | ||
) | ||
|
||
uri, body, headers = c.sign(u'http://server.example.com:80/init') | ||
|
||
headers = dict([(str(k), str(v)) for k, v in headers.iteritems()]) | ||
|
||
s = self.TestServer() | ||
self.assertTrue(s.check_request_signature(uri, body=body, | ||
headers=headers)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters