mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-17 23:13:00 +00:00
Fix tests after making the default load_managed_roles
raise
Four tests were not using a mock authenticator: - two get `reset_managed_roles_on_startup` toggled - two get a custom implementation of `load_managed_roles`
This commit is contained in:
@@ -1332,6 +1332,7 @@ async def test_manage_roles_allows_using_load_roles(role_spec):
|
|||||||
hub = MockHub(load_roles=roles_to_load)
|
hub = MockHub(load_roles=roles_to_load)
|
||||||
hub.init_db()
|
hub.init_db()
|
||||||
hub.authenticator.manage_roles = True
|
hub.authenticator.manage_roles = True
|
||||||
|
hub.authenticator.reset_managed_roles_on_startup = False
|
||||||
await hub.init_role_creation()
|
await hub.init_role_creation()
|
||||||
|
|
||||||
|
|
||||||
@@ -1339,11 +1340,16 @@ async def test_manage_roles_loads_default_roles():
|
|||||||
hub = MockHub()
|
hub = MockHub()
|
||||||
hub.init_db()
|
hub.init_db()
|
||||||
hub.authenticator.manage_roles = True
|
hub.authenticator.manage_roles = True
|
||||||
|
hub.authenticator.reset_managed_roles_on_startup = False
|
||||||
await hub.init_role_creation()
|
await hub.init_role_creation()
|
||||||
admin_role = orm.Role.find(hub.db, 'admin')
|
admin_role = orm.Role.find(hub.db, 'admin')
|
||||||
assert admin_role
|
assert admin_role
|
||||||
|
|
||||||
|
|
||||||
|
async def empty_load_managed_roles():
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
async def test_reset_managed_roles_clears_assignments(app):
|
async def test_reset_managed_roles_clears_assignments(app):
|
||||||
hub = MockHub()
|
hub = MockHub()
|
||||||
hub.init_db()
|
hub.init_db()
|
||||||
@@ -1363,6 +1369,8 @@ async def test_reset_managed_roles_clears_assignments(app):
|
|||||||
# on next startup the roles assignments managed by authenticator should be removed
|
# on next startup the roles assignments managed by authenticator should be removed
|
||||||
hub.authenticator.manage_roles = True
|
hub.authenticator.manage_roles = True
|
||||||
hub.authenticator.reset_managed_roles_on_startup = True
|
hub.authenticator.reset_managed_roles_on_startup = True
|
||||||
|
hub.authenticator.load_managed_roles = empty_load_managed_roles
|
||||||
|
|
||||||
await hub.init_role_creation()
|
await hub.init_role_creation()
|
||||||
assert len(user.roles) == 0
|
assert len(user.roles) == 0
|
||||||
|
|
||||||
@@ -1381,6 +1389,7 @@ async def test_reset_managed_roles_clears_managed_roles(app):
|
|||||||
|
|
||||||
hub.authenticator.manage_roles = True
|
hub.authenticator.manage_roles = True
|
||||||
hub.authenticator.reset_managed_roles_on_startup = True
|
hub.authenticator.reset_managed_roles_on_startup = True
|
||||||
|
hub.authenticator.load_managed_roles = empty_load_managed_roles
|
||||||
|
|
||||||
# on next startup the managed roles created by authenticator should be removed
|
# on next startup the managed roles created by authenticator should be removed
|
||||||
await hub.init_role_creation()
|
await hub.init_role_creation()
|
||||||
|
Reference in New Issue
Block a user