提交 1a0714e7 编写于 作者: B Ben Darnell

auth: Deprecated _oauth_get_user

上级 089b5e7e
......@@ -527,7 +527,14 @@ class OAuthMixin(object):
For backwards compatibility, the callback-based ``_oauth_get_user``
method is also supported.
.. deprecated:: 5.1
The ``_oauth_get_user`` fallback is deprecated and support for it
will be removed in 6.0.
"""
warnings.warn("_oauth_get_user is deprecated, override _oauth_get_user_future instead",
DeprecationWarning)
# By default, call the old-style _oauth_get_user, but new code
# should override this method instead.
self._oauth_get_user(access_token, callback)
......
......@@ -18,6 +18,7 @@ from tornado import gen
from tornado.httputil import url_concat
from tornado.log import gen_log
from tornado.testing import AsyncHTTPTestCase, ExpectLog
from tornado.test.util import ignore_deprecation
from tornado.web import RequestHandler, Application, asynchronous, HTTPError
......@@ -121,12 +122,13 @@ class OAuth1ClientLoginHandler(RequestHandler, OAuthMixin):
return
yield self.authorize_redirect(http_client=self.settings['http_client'])
def _oauth_get_user(self, access_token, callback):
@gen.coroutine
def _oauth_get_user_future(self, access_token):
if self.get_argument('fail_in_get_user', None):
raise Exception("failing in get_user")
if access_token != dict(key='uiop', secret='5678'):
raise Exception("incorrect access token %r" % access_token)
callback(dict(email='foo@example.com'))
return dict(email='foo@example.com')
class OAuth1ClientLoginCoroutineHandler(OAuth1ClientLoginHandler):
......@@ -465,9 +467,10 @@ class AuthTest(AsyncHTTPTestCase):
response.headers['Set-Cookie'])
def test_oauth10_get_user_legacy(self):
response = self.fetch(
'/legacy/oauth10/client/login?oauth_token=zxcv',
headers={'Cookie': '_oauth_request_token=enhjdg==|MTIzNA=='})
with ignore_deprecation():
response = self.fetch(
'/legacy/oauth10/client/login?oauth_token=zxcv',
headers={'Cookie': '_oauth_request_token=enhjdg==|MTIzNA=='})
response.rethrow()
parsed = json_decode(response.body)
self.assertEqual(parsed['email'], 'foo@example.com')
......@@ -502,9 +505,10 @@ class AuthTest(AsyncHTTPTestCase):
response.headers['Set-Cookie'])
def test_oauth10a_get_user_legacy(self):
response = self.fetch(
'/legacy/oauth10a/client/login?oauth_token=zxcv',
headers={'Cookie': '_oauth_request_token=enhjdg==|MTIzNA=='})
with ignore_deprecation():
response = self.fetch(
'/legacy/oauth10a/client/login?oauth_token=zxcv',
headers={'Cookie': '_oauth_request_token=enhjdg==|MTIzNA=='})
response.rethrow()
parsed = json_decode(response.body)
self.assertEqual(parsed['email'], 'foo@example.com')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册