Skip to content

Commit

Permalink
Assume jupyterhub >= 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
benjimin committed Jan 22, 2024
1 parent 0b37825 commit f6dab11
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
6 changes: 2 additions & 4 deletions oauthenticator/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,11 @@ async def update_auth_model(self, auth_model):
Also populates groups if `manage_groups` is set.
"""
# Authenticator.manage_groups is new in jupyterhub 2.2
manage_groups = getattr(self, "manage_groups", False)
if manage_groups or self.admin_groups:
if self.manage_groups or self.admin_groups:
user_info = auth_model["auth_state"][self.user_auth_state_key]
user_groups = self.get_user_groups(user_info)

if manage_groups:
if self.manage_groups:
auth_model["groups"] = sorted(user_groups)

if auth_model["admin"]:
Expand Down
7 changes: 1 addition & 6 deletions oauthenticator/tests/test_generic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json
from functools import partial

import pytest
from pytest import fixture, mark
from traitlets.config import Config

Expand Down Expand Up @@ -178,11 +177,7 @@ async def test_generic(
authenticator = get_authenticator(config=c)
manage_groups = False
if "manage_groups" in class_config:
try:
manage_groups = authenticator.manage_groups
except AttributeError:
pytest.skip("manage_groups requires jupyterhub 2.2")
1 / 0
manage_groups = authenticator.manage_groups

handled_user_model = user_model("user1")
handler = generic_client.handler_for_user(handled_user_model)
Expand Down

0 comments on commit f6dab11

Please sign in to comment.