summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2013-01-04 11:58:42 -0500
committerBarry Warsaw <barry@python.org>2013-01-04 11:58:42 -0500
commita9deb08f529cff605b2fb8ab5106832ad06cb9d7 (patch)
tree998dc5a56168b2e89edcff33b880670f42511475
parent43124ab671f73e33a6a5f608dcb4afd997619a8f (diff)
downloadoauthlib-a9deb08f529cff605b2fb8ab5106832ad06cb9d7.tar.gz
Fix a typo in the code that converts arguments from bytes to unicodes.
-rw-r--r--oauthlib/oauth1/rfc5849/__init__.py4
-rw-r--r--tests/oauth1/rfc5849/test_client.py12
2 files changed, 13 insertions, 3 deletions
diff --git a/oauthlib/oauth1/rfc5849/__init__.py b/oauthlib/oauth1/rfc5849/__init__.py
index f3dcd22..fed413d 100644
--- a/oauthlib/oauth1/rfc5849/__init__.py
+++ b/oauthlib/oauth1/rfc5849/__init__.py
@@ -54,8 +54,8 @@ class Client(object):
client_key = client_key.decode(encoding)
if isinstance(client_secret, bytes_type):
client_secret = client_secret.decode(encoding)
- if isinstance(resource_owner, bytes_type):
- resource_owner = resource_owner.decode(encoding)
+ if isinstance(resource_owner_key, bytes_type):
+ resource_owner_key = resource_owner_key.decode(encoding)
if isinstance(resource_owner_secret, bytes_type):
resource_owner_secret = resource_owner_secret.decode(encoding)
if isinstance(callback_uri, bytes_type):
diff --git a/tests/oauth1/rfc5849/test_client.py b/tests/oauth1/rfc5849/test_client.py
index 5cc1f7e..c2b877e 100644
--- a/tests/oauth1/rfc5849/test_client.py
+++ b/tests/oauth1/rfc5849/test_client.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
-from oauthlib.oauth1.rfc5849 import Client
+from oauthlib.oauth1.rfc5849 import Client, bytes_type
from ...unittest import TestCase
@@ -27,3 +27,13 @@ class ClientRealmTests(TestCase):
header["Authorization"].startswith('OAuth realm="baa-realm",'))
# make sure sign() does not override the default realm
self.assertEqual(client.realm, "moo-realm")
+
+
+class ClientConstructorTests(TestCase):
+
+ def test_convert_to_unicode_resource_owner(self):
+ client = Client('client-key',
+ resource_owner_key=b'owner key',
+ convert_to_unicode=True)
+ self.assertFalse(isinstance(client.resource_owner_key, bytes_type))
+ self.assertEqual(client.resource_owner_key, 'owner key')