mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
test refactor: remove test with broken assumption
To remove a user from the admin list doesn't matter, even though its clearly something one may expect should matter. The issue is that JupyterHub itself makes use of the admin_users list as a way to declare new admins, not to remove users having been marked as admin in the past. What to do about this is not clear, but having a test for this doesn't make sense.
This commit is contained in:
@@ -163,73 +163,6 @@ async def test_user_admin_add():
|
||||
assert f"jupyter-{username}" in grp.getgrnam("jupyterhub-admins").gr_mem
|
||||
|
||||
|
||||
# FIXME: Make this test pass
|
||||
@pytest.mark.xfail(reason="Unclear why this is failing")
|
||||
async def test_user_admin_remove():
|
||||
"""
|
||||
User is made an admin, logs in and we check if they are in admin group.
|
||||
|
||||
Then we remove them from admin group, and check they *aren't* in admin group :D
|
||||
"""
|
||||
# This *must* be localhost, not an IP
|
||||
# aiohttp throws away cookies if we are connecting to an IP!
|
||||
username = secrets.token_hex(8)
|
||||
|
||||
assert (
|
||||
0
|
||||
== await (
|
||||
await asyncio.create_subprocess_exec(
|
||||
*TLJH_CONFIG_PATH, "set", "auth.type", "dummy"
|
||||
)
|
||||
).wait()
|
||||
)
|
||||
assert (
|
||||
0
|
||||
== await (
|
||||
await asyncio.create_subprocess_exec(
|
||||
*TLJH_CONFIG_PATH, "add-item", "users.admin", username
|
||||
)
|
||||
).wait()
|
||||
)
|
||||
assert (
|
||||
0
|
||||
== await (
|
||||
await asyncio.create_subprocess_exec(*TLJH_CONFIG_PATH, "reload")
|
||||
).wait()
|
||||
)
|
||||
|
||||
async with User(username, hub_url, partial(login_dummy, password="")) as u:
|
||||
await u.login()
|
||||
await u.ensure_server_simulate(timeout=60, spawn_refresh_time=5)
|
||||
|
||||
# Assert that the user exists
|
||||
assert pwd.getpwnam(f"jupyter-{username}") is not None
|
||||
|
||||
# Assert that the user has admin rights
|
||||
assert f"jupyter-{username}" in grp.getgrnam("jupyterhub-admins").gr_mem
|
||||
|
||||
assert (
|
||||
0
|
||||
== await (
|
||||
await asyncio.create_subprocess_exec(
|
||||
*TLJH_CONFIG_PATH, "remove-item", "users.admin", username
|
||||
)
|
||||
).wait()
|
||||
)
|
||||
assert (
|
||||
0
|
||||
== await (
|
||||
await asyncio.create_subprocess_exec(*TLJH_CONFIG_PATH, "reload")
|
||||
).wait()
|
||||
)
|
||||
|
||||
await u.stop_server()
|
||||
await u.ensure_server_simulate(timeout=60, spawn_refresh_time=5)
|
||||
|
||||
# Assert that the user does *not* have admin rights
|
||||
assert f"jupyter-{username}" not in grp.getgrnam("jupyterhub-admins").gr_mem
|
||||
|
||||
|
||||
async def test_long_username():
|
||||
"""
|
||||
User with a long name logs in, and we check if their name is properly truncated.
|
||||
|
||||
Reference in New Issue
Block a user