diff --git a/multiauthenticator/tests/test_multiauthenticator.py b/multiauthenticator/tests/test_multiauthenticator.py index 83e28de..5ec313a 100644 --- a/multiauthenticator/tests/test_multiauthenticator.py +++ b/multiauthenticator/tests/test_multiauthenticator.py @@ -4,6 +4,7 @@ """Test module for the MultiAuthenticator class""" import pytest +from jupyterhub.auth import DummyAuthenticator from jupyterhub.auth import PAMAuthenticator from oauthenticator.github import GitHubOAuthenticator from oauthenticator.gitlab import GitLabOAuthenticator @@ -205,8 +206,28 @@ def test_username_prefix(): multi_authenticator = MultiAuthenticator() assert len(multi_authenticator._authenticators) == 2 - assert multi_authenticator._authenticators[0].username_prefix == "GitLab:" - assert multi_authenticator._authenticators[1].username_prefix == "PAM:" + assert ( + multi_authenticator._authenticators[0].username_prefix + == f"GitLab{PREFIX_SEPARATOR}" + ) + assert ( + multi_authenticator._authenticators[1].username_prefix + == f"PAM{PREFIX_SEPARATOR}" + ) + + +@pytest.mark.asyncio +async def test_authenticated_username_prefix(): + MultiAuthenticator.authenticators = [ + (DummyAuthenticator, "/pam", {"service_name": "Dummy"}), + ] + + multi_authenticator = MultiAuthenticator() + assert len(multi_authenticator._authenticators) == 1 + username = await multi_authenticator._authenticators[0].authenticate( + None, {"username": "test"} + ) + assert username == f"Dummy{PREFIX_SEPARATOR}test" def test_username_prefix_checks(): diff --git a/pyproject.toml b/pyproject.toml index 249b890..86542b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ dependencies = [ ] [project.optional-dependencies] -test = ["pytest", "pytest-cov"] +test = ["pytest", "pytest-cov", "pytest-asyncio"] dev = ["pre-commit", "jupyterhub-multiauthenticator[test]"] [tool.setuptools]