Skip to content

Commit

Permalink
test: ensure next handling is working as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
sgaist committed Nov 20, 2023
1 parent 0132e54 commit dc01223
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 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 jinja2 import Template
from jupyterhub.auth import DummyAuthenticator
from jupyterhub.auth import PAMAuthenticator
from oauthenticator import OAuthenticator
Expand Down Expand Up @@ -297,3 +298,27 @@ class MyAuthenticator(OAuthenticator):
MultiAuthenticator()

assert f"Login service cannot contain {PREFIX_SEPARATOR}" in str(excinfo.value)


def test_next_handling():
MultiAuthenticator.authenticators = [
(
PAMAuthenticator,
"/pam",
{"service_name": "test-service", "allowed_users": {"test"}},
),
]

multi_authenticator = MultiAuthenticator()
html = multi_authenticator.get_custom_html("")

template = Template(html)

with_next = template.render({"next": "/next-destination"})
assert "href='pam/login?next=/next-destination'" in with_next

without_next = template.render()
assert "href='pam/login'" in without_next

with_empty_next = template.render({"next": ""})
assert "href='pam/login'" in with_empty_next

0 comments on commit dc01223

Please sign in to comment.