mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-15 14:03:02 +00:00

- add docs, tests - deprecate DummyAuthenticator.password, pointing to new class - accept no password as valid config (no login possible) - log warnings for suspicious config (e.g. passwords not set, admin password set, but no admin users, etc.)
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
"""Tests for dummy authentication"""
|
|
|
|
# Copyright (c) Jupyter Development Team.
|
|
# Distributed under the terms of the Modified BSD License.
|
|
|
|
from jupyterhub.auth import DummyAuthenticator
|
|
|
|
|
|
async def test_dummy_auth_without_global_password():
|
|
authenticator = DummyAuthenticator()
|
|
authorized = await authenticator.get_authenticated_user(
|
|
None, {'username': 'test_user', 'password': 'test_pass'}
|
|
)
|
|
assert authorized['name'] == 'test_user'
|
|
|
|
authorized = await authenticator.get_authenticated_user(
|
|
None, {'username': 'test_user', 'password': ''}
|
|
)
|
|
assert authorized['name'] == 'test_user'
|
|
|
|
|
|
async def test_dummy_auth_without_username():
|
|
authenticator = DummyAuthenticator()
|
|
authorized = await authenticator.get_authenticated_user(
|
|
None, {'username': '', 'password': 'test_pass'}
|
|
)
|
|
assert authorized is None
|
|
|
|
|
|
async def test_dummy_auth_with_global_password():
|
|
authenticator = DummyAuthenticator()
|
|
authenticator.password = "test_password"
|
|
|
|
authorized = await authenticator.get_authenticated_user(
|
|
None, {'username': 'test_user', 'password': 'test_password'}
|
|
)
|
|
assert authorized['name'] == 'test_user'
|
|
|
|
authorized = await authenticator.get_authenticated_user(
|
|
None, {'username': 'test_user', 'password': 'qwerty'}
|
|
)
|
|
assert authorized is None
|
|
|
|
authorized = await authenticator.get_authenticated_user(
|
|
None, {'username': 'some_other_user', 'password': 'test_password'}
|
|
)
|
|
assert authorized['name'] == 'some_other_user'
|