Files
the-littlest-jupyterhub/integration-tests/test_admin_installer.py

40 lines
1.1 KiB
Python
Raw Normal View History

2019-07-16 20:18:45 +03:00
from functools import partial
import pytest
from hubtraf.auth.dummy import login_dummy
from hubtraf.user import User
hub_url = "http://localhost"
2019-07-16 20:18:45 +03:00
async def test_admin_login():
"""
Test if the admin that was added during install can login with
the password provided.
"""
username = "test-admin-username"
password = "test-admin-password"
2019-07-16 20:18:45 +03:00
async with User(username, hub_url, partial(login_dummy, password=password)) as u:
await u.login()
# If user is not logged in, this will raise an exception
await u.ensure_server_simulate(timeout=60, spawn_refresh_time=5)
2019-07-16 20:18:45 +03:00
2019-07-16 20:18:45 +03:00
@pytest.mark.parametrize(
"username, password",
[
("test-admin-username", ""),
("test-admin-username", "wrong_passw"),
2019-07-16 20:18:45 +03:00
("user", "password"),
],
)
async def test_unsuccessful_login(username, password):
"""
Ensure nobody but the admin that was added during install can login
"""
async with User(username, hub_url, partial(login_dummy, password="")) as u:
user_logged_in = await u.login()
assert user_logged_in == False