Update append_query_parameters to have exclude=["none"] by default,

and avoid using dicts with url_concat, to have consistent tests
as otherwise in Python 3.5 the generated URL's could have parameters
in random order.
This commit is contained in:
Bruno P. Kinoshita
2020-06-23 20:11:49 +12:00
parent d4ce3aa731
commit 73f1211286
2 changed files with 11 additions and 5 deletions

View File

@@ -668,12 +668,18 @@ class BaseHandler(RequestHandler):
This is important to avoid infinite loops with the next parameter being
added over and over, for instance.
The default value for ``exclude`` is an array with "next". This is useful
as most use cases in JupyterHub (all?) won't want to include the next
parameter twice (the next parameter is added elsewhere to the query
parameters).
:param str url: a URL
:param list exclude: optional list of parameters to be ignored
:param list exclude: optional list of parameters to be ignored, defaults to
a list with "next" (to avoid redirect-loops)
:rtype (str)
"""
if not exclude:
exclude = []
exclude = ['next']
if self.request.query:
query_string = [
param

View File

@@ -517,7 +517,7 @@ async def test_user_redirect_deprecated(app, username):
async def test_login_page(app):
url = url_concat('login', dict(next='foo', param1='test'))
url = url_concat('login', [('next', 'foo'), ('param1', 'test')])
r = await get_page(url, app)
assert r.url.endswith('/hub/login?next=foo&param1=test')
# now the login.html rendered template must include the given parameters in the form
@@ -577,8 +577,8 @@ async def test_login_strip(app):
(False, '///other.domain/triple', '', None),
(False, '\\\\other.domain/backslashes', '', None),
# params are handled correctly
(True, '/hub/admin', 'hub/admin?left=1&right=2', dict(left=1, right=2)),
(False, '/hub/admin', 'hub/admin?left=1&right=2', dict(left=1, right=2)),
(True, '/hub/admin', 'hub/admin?left=1&right=2', [('left', 1), ('right', 2)]),
(False, '/hub/admin', 'hub/admin?left=1&right=2', [('left', 1), ('right', 2)]),
],
)
async def test_login_redirect(app, running, next_url, location, params):