diff --git a/integration-tests/test_admin_installer.py b/integration-tests/test_admin_installer.py index 3b910cc..7eb2533 100644 --- a/integration-tests/test_admin_installer.py +++ b/integration-tests/test_admin_installer.py @@ -1,20 +1,48 @@ +import asyncio from functools import partial import pytest from hubtraf.auth.dummy import login_dummy from hubtraf.user import User +# Use sudo to invoke it, since this is how users invoke it. +# This catches issues with PATH +TLJH_CONFIG_PATH = ["sudo", "tljh-config"] + +# This *must* be localhost, not an IP +# aiohttp throws away cookies if we are connecting to an IP! HUB_URL = "http://localhost" +# FIXME: Other tests may have set the auth.type to dummy, so we reset it here to +# get the default of firstuseauthenticator. Tests should cleanup after +# themselves to a better degree, but its a bit trouble to reload the +# jupyterhub between each test as well if thats needed... +async def test_restore_relevant_tljh_state(): + assert ( + 0 + == await ( + await asyncio.create_subprocess_exec( + *TLJH_CONFIG_PATH, + "set", + "auth.type", + "firstuseauthenticator.FirstUseAuthenticator", + ) + ).wait() + ) + assert ( + 0 + == await ( + await asyncio.create_subprocess_exec(*TLJH_CONFIG_PATH, "reload") + ).wait() + ) + + @pytest.mark.parametrize( "username, password, expect_successful_login", [ - ("test-admin-username", "wrong_passw", False), ("test-admin-username", "test-admin-password", True), - ("test-admin-username", "", False), ("user", "", False), - ("user", "password", False), ], ) async def test_pre_configured_admin_login(username, password, expect_successful_login):