mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-11 03:52:59 +00:00
remove redundant user_url utility
public_url works for users now
This commit is contained in:
@@ -221,17 +221,6 @@ def public_url(app, user_or_service=None):
|
|||||||
return public_host(app) + app.proxy.public_server.base_url
|
return public_host(app) + app.proxy.public_server.base_url
|
||||||
|
|
||||||
|
|
||||||
def user_url(user, app):
|
|
||||||
"""Return the full public URL for a given user.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
user: user object, as return by app.users['username']
|
|
||||||
app: MockHub instance
|
|
||||||
Returns:
|
|
||||||
url (str): The public URL for user.
|
|
||||||
"""
|
|
||||||
return public_url(app, user)
|
|
||||||
|
|
||||||
# single-user-server mocking:
|
# single-user-server mocking:
|
||||||
|
|
||||||
class MockSingleUserServer(SingleUserNotebookApp):
|
class MockSingleUserServer(SingleUserNotebookApp):
|
||||||
|
@@ -15,7 +15,7 @@ from .. import orm
|
|||||||
from ..user import User
|
from ..user import User
|
||||||
from ..utils import url_path_join as ujoin
|
from ..utils import url_path_join as ujoin
|
||||||
from . import mocking
|
from . import mocking
|
||||||
from .mocking import public_host, public_url, user_url
|
from .mocking import public_host, public_url
|
||||||
|
|
||||||
|
|
||||||
def check_db_locks(func):
|
def check_db_locks(func):
|
||||||
@@ -366,7 +366,7 @@ def test_spawn(app, io_loop):
|
|||||||
assert status is None
|
assert status is None
|
||||||
|
|
||||||
assert user.server.base_url == ujoin(app.base_url, 'user/%s' % name)
|
assert user.server.base_url == ujoin(app.base_url, 'user/%s' % name)
|
||||||
url = user_url(user, app)
|
url = public_url(app, user)
|
||||||
print(url)
|
print(url)
|
||||||
r = requests.get(url)
|
r = requests.get(url)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
|
@@ -8,7 +8,7 @@ from ..utils import url_path_join as ujoin
|
|||||||
from .. import orm
|
from .. import orm
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from .mocking import FormSpawner, public_url, public_host, user_url
|
from .mocking import FormSpawner, public_url, public_host
|
||||||
from .test_api import api_request
|
from .test_api import api_request
|
||||||
|
|
||||||
def get_page(path, app, hub=True, **kw):
|
def get_page(path, app, hub=True, **kw):
|
||||||
@@ -35,7 +35,7 @@ def test_root_auth(app):
|
|||||||
cookies = app.login_user('river')
|
cookies = app.login_user('river')
|
||||||
r = requests.get(public_url(app), cookies=cookies)
|
r = requests.get(public_url(app), cookies=cookies)
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
assert r.url == user_url(app.users['river'], app)
|
assert r.url == public_url(app, app.users['river'])
|
||||||
|
|
||||||
def test_root_redirect(app):
|
def test_root_redirect(app):
|
||||||
name = 'wash'
|
name = 'wash'
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from .mocking import TestSingleUserSpawner, user_url
|
from .mocking import TestSingleUserSpawner, public_url
|
||||||
from ..utils import url_path_join
|
from ..utils import url_path_join
|
||||||
|
|
||||||
def test_singleuser_auth(app, io_loop):
|
def test_singleuser_auth(app, io_loop):
|
||||||
@@ -15,7 +15,7 @@ def test_singleuser_auth(app, io_loop):
|
|||||||
user = app.users['nandy']
|
user = app.users['nandy']
|
||||||
if not user.running:
|
if not user.running:
|
||||||
io_loop.run_sync(user.spawn)
|
io_loop.run_sync(user.spawn)
|
||||||
url = user_url(user, app)
|
url = public_url(app, user)
|
||||||
|
|
||||||
# no cookies, redirects to login page
|
# no cookies, redirects to login page
|
||||||
r = requests.get(url)
|
r = requests.get(url)
|
||||||
@@ -49,7 +49,7 @@ def test_disable_user_config(app, io_loop):
|
|||||||
io_loop.run_sync(user.spawn)
|
io_loop.run_sync(user.spawn)
|
||||||
io_loop.run_sync(lambda : app.proxy.add_user(user))
|
io_loop.run_sync(lambda : app.proxy.add_user(user))
|
||||||
|
|
||||||
url = user_url(user, app)
|
url = public_url(app, user)
|
||||||
|
|
||||||
# with cookies, login successful
|
# with cookies, login successful
|
||||||
r = requests.get(url, cookies=cookies)
|
r = requests.get(url, cookies=cookies)
|
||||||
|
Reference in New Issue
Block a user