Skip to content

Commit b168818

Browse files
committed
auth: Formally deprecated OpenIDMixin
Cherry-picks c47659a from master to branch-6.5. Modified to accelerate deprecation timeline to 6.7 instead of 7.0.
1 parent da28476 commit b168818

2 files changed

Lines changed: 48 additions & 21 deletions

File tree

‎tornado/auth.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,19 @@ class OpenIdMixin:
9898
Class attributes:
9999
100100
* ``_OPENID_ENDPOINT``: the identity provider's URI.
101+
102+
.. deprecated:: 6.6
103+
OpenID 2.0 is no longer widely supported by identity providers.
104+
This class will be removed in Tornado 6.7.
101105
"""
102106

107+
def __init__(self) -> None:
108+
warnings.warn(
109+
"OpenIdMixin is deprecated and will be removed in Tornado 6.7",
110+
DeprecationWarning,
111+
stacklevel=2,
112+
)
113+
103114
def authenticate_redirect(
104115
self,
105116
callback_uri: Optional[str] = None,

‎tornado/test/auth_test.py‎

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
from tornado.httpclient import HTTPClientError
1919
from tornado.httputil import url_concat
2020
from tornado.log import app_log
21-
from tornado.testing import AsyncHTTPTestCase, ExpectLog
21+
from tornado.testing import AsyncHTTPTestCase, ExpectLog, setup_with_context_manager
22+
from tornado.test.util import ignore_deprecation
2223
from tornado.web import RequestHandler, Application, HTTPError
2324

2425
try:
@@ -279,12 +280,46 @@ def get(self):
279280
self.write(dict(screen_name="foo", name="Foo"))
280281

281282

283+
class OpenIDAuthTest(AsyncHTTPTestCase):
284+
def setUp(self):
285+
setup_with_context_manager(self, ignore_deprecation())
286+
return super().setUp()
287+
288+
def get_app(self):
289+
return Application(
290+
[
291+
("/openid/client/login", OpenIdClientLoginHandler, dict(test=self)),
292+
("/openid/server/authenticate", OpenIdServerAuthenticateHandler),
293+
],
294+
http_client=self.http_client,
295+
)
296+
297+
def test_openid_redirect(self):
298+
with ignore_deprecation():
299+
response = self.fetch("/openid/client/login", follow_redirects=False)
300+
self.assertEqual(response.code, 302)
301+
self.assertIn("/openid/server/authenticate?", response.headers["Location"])
302+
303+
def test_openid_get_user(self):
304+
for i in range(2):
305+
with self.subTest(i=i):
306+
with ignore_deprecation():
307+
response = self.fetch(
308+
"/openid/client/login?openid.mode=blah"
309+
"&openid.ns.ax=http://openid.net/srv/ax/1.0"
310+
"&openid.ax.type.email=http://axschema.org/contact/email"
311+
312+
)
313+
response.rethrow()
314+
parsed = json_decode(response.body)
315+
self.assertEqual(parsed["email"], "[email protected]")
316+
317+
282318
class AuthTest(AsyncHTTPTestCase):
283319
def get_app(self):
284320
return Application(
285321
[
286322
# test endpoints
287-
("/openid/client/login", OpenIdClientLoginHandler, dict(test=self)),
288323
(
289324
"/oauth10/client/login",
290325
OAuth1ClientLoginHandler,
@@ -329,7 +364,6 @@ def get_app(self):
329364
dict(test=self),
330365
),
331366
# simulated servers
332-
("/openid/server/authenticate", OpenIdServerAuthenticateHandler),
333367
("/oauth1/server/request_token", OAuth1ServerRequestTokenHandler),
334368
("/oauth1/server/access_token", OAuth1ServerAccessTokenHandler),
335369
("/facebook/server/access_token", FacebookServerAccessTokenHandler),
@@ -348,24 +382,6 @@ def get_app(self):
348382
facebook_secret="test_facebook_secret",
349383
)
350384

351-
def test_openid_redirect(self):
352-
response = self.fetch("/openid/client/login", follow_redirects=False)
353-
self.assertEqual(response.code, 302)
354-
self.assertIn("/openid/server/authenticate?", response.headers["Location"])
355-
356-
def test_openid_get_user(self):
357-
for i in range(2):
358-
with self.subTest(i=i):
359-
response = self.fetch(
360-
"/openid/client/login?openid.mode=blah"
361-
"&openid.ns.ax=http://openid.net/srv/ax/1.0"
362-
"&openid.ax.type.email=http://axschema.org/contact/email"
363-
364-
)
365-
response.rethrow()
366-
parsed = json_decode(response.body)
367-
self.assertEqual(parsed["email"], "[email protected]")
368-
369385
def test_oauth10_redirect(self):
370386
response = self.fetch("/oauth10/client/login", follow_redirects=False)
371387
self.assertEqual(response.code, 302)

0 commit comments

Comments
 (0)