Skip to content

Commit

Permalink
fix: adapt tests to JupyterHub version
Browse files Browse the repository at this point in the history
Since version 5, the logic of check_allowed has changed for
a more secure version.
  • Loading branch information
sgaist committed Jul 19, 2024
1 parent 391e648 commit 56e9480
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions multiauthenticator/tests/test_multiauthenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# SPDX-License-Identifier: BSD-3-Clause
"""Test module for the MultiAuthenticator class"""
import jupyterhub
import pytest

from jinja2 import Template
Expand All @@ -11,6 +12,7 @@
from oauthenticator.github import GitHubOAuthenticator
from oauthenticator.gitlab import GitLabOAuthenticator
from oauthenticator.google import GoogleOAuthenticator
from packaging.version import Version

from ..multiauthenticator import PREFIX_SEPARATOR
from ..multiauthenticator import MultiAuthenticator
Expand Down Expand Up @@ -275,9 +277,12 @@ def test_username_prefix_checks():

authenticator = multi_authenticator._authenticators[1]
assert authenticator.check_allowed("test2") == False
assert (
authenticator.check_allowed("pam2:test2") == True
) # Because allowed_users is empty
if Version(jupyterhub.__version__) < Version("5"):
assert (
authenticator.check_allowed("pam2:test2") == True
) # Because allowed_users is empty
else:
assert authenticator.check_allowed("pam2:test2") == False
assert (
authenticator.check_blocked_users("test2") == False
) # Because of missing prefix
Expand Down

0 comments on commit 56e9480

Please sign in to comment.