Skip to content

Commit

Permalink
test: add authenticate method check
Browse files Browse the repository at this point in the history
  • Loading branch information
sgaist committed Oct 7, 2023
1 parent fb0cc77 commit c7c2e4d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 23 additions & 2 deletions multiauthenticator/tests/test_multiauthenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit c7c2e4d

Please sign in to comment.