diff --git a/tests/tests_deployment/test_jupyterhub_api.py b/tests/tests_deployment/test_jupyterhub_api.py new file mode 100644 index 000000000..e7e3fe3ec --- /dev/null +++ b/tests/tests_deployment/test_jupyterhub_api.py @@ -0,0 +1,21 @@ +import pytest +import requests + +from tests.tests_deployment import constants +from tests.tests_deployment.utils import get_jupyterhub_token + + +@pytest.fixture(scope="session") +def api_token(): + return get_jupyterhub_token("jupyterhub-api") + + +@pytest.mark.filterwarnings("ignore::urllib3.exceptions.InsecureRequestWarning") +def test_jupyterhub_loads_roles_from_keycloak(api_token): + response = requests.get( + f"https://{constants.NEBARI_HOSTNAME}/hub/api/user/{constants.KEYCLOAK_USERNAME}", + headers={"Authorization": f"Bearer {api_token}"}, + verify=False, + ) + user = response.json() + assert user["roles"] == []