aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/requests-oauthlib/tests/test_oauth1_session.py
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-03-25 09:11:17 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-03-25 09:17:48 +0300
commit4624e4cfd95649270db02616edde8d0ca249b63d (patch)
tree1c8a43f50533ca759d137f258e42862e8cf5e80f /contrib/python/requests-oauthlib/tests/test_oauth1_session.py
parentd2d971701bd8377ead5f973c96be81042774bd2a (diff)
downloadydb-4624e4cfd95649270db02616edde8d0ca249b63d.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/python/requests-oauthlib/tests/test_oauth1_session.py')
-rw-r--r--contrib/python/requests-oauthlib/tests/test_oauth1_session.py39
1 files changed, 11 insertions, 28 deletions
diff --git a/contrib/python/requests-oauthlib/tests/test_oauth1_session.py b/contrib/python/requests-oauthlib/tests/test_oauth1_session.py
index 1dd2b2f158..b3c8c70483 100644
--- a/contrib/python/requests-oauthlib/tests/test_oauth1_session.py
+++ b/contrib/python/requests-oauthlib/tests/test_oauth1_session.py
@@ -1,19 +1,13 @@
-from __future__ import unicode_literals, print_function
import unittest
-import sys
import requests
from io import StringIO
+from unittest import mock
from oauthlib.oauth1 import SIGNATURE_TYPE_QUERY, SIGNATURE_TYPE_BODY
from oauthlib.oauth1 import SIGNATURE_RSA, SIGNATURE_PLAINTEXT
from requests_oauthlib import OAuth1Session
try:
- import mock
-except ImportError:
- from unittest import mock
-
-try:
import cryptography
except ImportError:
cryptography = None
@@ -23,11 +17,6 @@ try:
except ImportError:
jwt = None
-if sys.version[0] == "3":
- unicode_type = str
-else:
- unicode_type = unicode
-
TEST_RSA_KEY = (
"-----BEGIN RSA PRIVATE KEY-----\n"
@@ -165,8 +154,8 @@ class OAuth1SessionTest(unittest.TestCase):
self.assertEqual(resp["oauth_token"], "foo")
self.assertEqual(resp["oauth_verifier"], "bar")
for k, v in resp.items():
- self.assertIsInstance(k, unicode_type)
- self.assertIsInstance(v, unicode_type)
+ self.assertIsInstance(k, str)
+ self.assertIsInstance(v, str)
def test_fetch_request_token(self):
auth = OAuth1Session("foo")
@@ -174,8 +163,8 @@ class OAuth1SessionTest(unittest.TestCase):
resp = auth.fetch_request_token("https://example.com/token")
self.assertEqual(resp["oauth_token"], "foo")
for k, v in resp.items():
- self.assertIsInstance(k, unicode_type)
- self.assertIsInstance(v, unicode_type)
+ self.assertIsInstance(k, str)
+ self.assertIsInstance(v, str)
def test_fetch_request_token_with_optional_arguments(self):
auth = OAuth1Session("foo")
@@ -185,8 +174,8 @@ class OAuth1SessionTest(unittest.TestCase):
)
self.assertEqual(resp["oauth_token"], "foo")
for k, v in resp.items():
- self.assertIsInstance(k, unicode_type)
- self.assertIsInstance(v, unicode_type)
+ self.assertIsInstance(k, str)
+ self.assertIsInstance(v, str)
def test_fetch_access_token(self):
auth = OAuth1Session("foo", verifier="bar")
@@ -194,8 +183,8 @@ class OAuth1SessionTest(unittest.TestCase):
resp = auth.fetch_access_token("https://example.com/token")
self.assertEqual(resp["oauth_token"], "foo")
for k, v in resp.items():
- self.assertIsInstance(k, unicode_type)
- self.assertIsInstance(v, unicode_type)
+ self.assertIsInstance(k, str)
+ self.assertIsInstance(v, str)
def test_fetch_access_token_with_optional_arguments(self):
auth = OAuth1Session("foo", verifier="bar")
@@ -205,8 +194,8 @@ class OAuth1SessionTest(unittest.TestCase):
)
self.assertEqual(resp["oauth_token"], "foo")
for k, v in resp.items():
- self.assertIsInstance(k, unicode_type)
- self.assertIsInstance(v, unicode_type)
+ self.assertIsInstance(k, str)
+ self.assertIsInstance(v, str)
def _test_fetch_access_token_raises_error(self, auth):
"""Assert that an error is being raised whenever there's no verifier
@@ -308,12 +297,6 @@ class OAuth1SessionTest(unittest.TestCase):
generate_nonce.return_value = "abc"
generate_timestamp.return_value = "123"
- signature = (
- "OAuth "
- 'oauth_nonce="abc", oauth_timestamp="123", oauth_version="1.0", '
- 'oauth_signature_method="RSA-SHA1", oauth_consumer_key="foo", '
- 'oauth_verifier="bar", oauth_signature="{sig}"'
- ).format(sig=TEST_RSA_OAUTH_SIGNATURE)
sess = OAuth1Session(
"key",
"secret",