mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-16 14:33:00 +00:00
raise 404 on admin attempt to spawn nonexistent user
This commit is contained in:
@@ -484,6 +484,11 @@ class UserServerAPIHandler(APIHandler):
|
|||||||
@needs_scope('servers')
|
@needs_scope('servers')
|
||||||
async def post(self, user_name, server_name=''):
|
async def post(self, user_name, server_name=''):
|
||||||
user = self.find_user(user_name)
|
user = self.find_user(user_name)
|
||||||
|
if user is None:
|
||||||
|
# this can be reached if a token has `servers`
|
||||||
|
# permission on *all* users
|
||||||
|
raise web.HTTPError(404)
|
||||||
|
|
||||||
if server_name:
|
if server_name:
|
||||||
if not self.allow_named_servers:
|
if not self.allow_named_servers:
|
||||||
raise web.HTTPError(400, "Named servers are not enabled.")
|
raise web.HTTPError(400, "Named servers are not enabled.")
|
||||||
|
@@ -972,6 +972,11 @@ async def test_bad_spawn(app, bad_spawn):
|
|||||||
assert app.users.count_active_users()['pending'] == 0
|
assert app.users.count_active_users()['pending'] == 0
|
||||||
|
|
||||||
|
|
||||||
|
async def test_spawn_nosuch_user(app):
|
||||||
|
r = await api_request(app, 'users', "nosuchuser", 'server', method='post')
|
||||||
|
assert r.status_code == 404
|
||||||
|
|
||||||
|
|
||||||
async def test_slow_bad_spawn(app, no_patience, slow_bad_spawn):
|
async def test_slow_bad_spawn(app, no_patience, slow_bad_spawn):
|
||||||
db = app.db
|
db = app.db
|
||||||
name = 'zaphod'
|
name = 'zaphod'
|
||||||
|
Reference in New Issue
Block a user