diff --git a/.circleci/config.yml b/.circleci/config.yml index 31e5b605f..fd4b98a0c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -77,6 +77,13 @@ jobs: python3 .circleci/integration-test.py copy . /srv/src python3 .circleci/integration-test.py run 'python3 /srv/src/bootstrap/bootstrap.py' + + - run: + name: switch to dummyauthenticator + command: | + python3 .circleci/integration-test.py run '/opt/tljh/hub/bin/tljh-config set auth.type dummyauthenticator.DummyAuthenticator' + python3 .circleci/integration-test.py run '/opt/tljh/hub/bin/tljh-config reload' + - run: name: print systemd status + logs command: | diff --git a/integration-tests/requirements.txt b/integration-tests/requirements.txt index 547de5c5b..271c563cc 100644 --- a/integration-tests/requirements.txt +++ b/integration-tests/requirements.txt @@ -1,2 +1,3 @@ pytest -requests +pytest-asyncio +git+https://github.com/yuvipanda/hubtraf.git \ No newline at end of file diff --git a/integration-tests/test_hub.py b/integration-tests/test_hub.py index d5d6cb05d..4d3c66030 100644 --- a/integration-tests/test_hub.py +++ b/integration-tests/test_hub.py @@ -1,5 +1,29 @@ import requests +from hubtraf.user import User +from hubtraf.auth.dummy import login_dummy +import secrets +import pytest +from functools import partial +import pwd + def test_hub_up(): r = requests.get('http://127.0.0.1') r.raise_for_status() + + +@pytest.mark.asyncio +async def test_user_login(): + # This *must* be localhost, not an IP + # aiohttp throws away cookies if we are connecting to an IP! + hub_url = 'http://localhost' + username = secrets.token_hex(8) + + async with User(username, hub_url, partial(login_dummy, password='')) as u: + await u.login() + await u.ensure_server() + await u.start_kernel() + await u.assert_code_output("5 * 4", "20", 5, 5) + + # Assert that the user exists + assert pwd.getpwnam(f'jupyter-{username}') is not None \ No newline at end of file