Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed May 6, 2024
1 parent f8da2f9 commit 3fe718c
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions tests/tests_deployment/test_jupyterhub_api.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
import pytest

from tests.tests_deployment import constants
from tests.tests_deployment.utils import get_jupyterhub_session


@pytest.mark.filterwarnings("ignore::urllib3.exceptions.InsecureRequestWarning")
def test_jupyterhub_loads_roles_from_keycloak():
session = get_jupyterhub_session()
xsrf_token = session.cookies.get("_xsrf")
response = session.get(
f"https://{constants.NEBARI_HOSTNAME}/hub/api/users",
f"https://{constants.NEBARI_HOSTNAME}/hub/api/users/{constants.KEYCLOAK_USERNAME}",
headers={"X-XSRFToken": xsrf_token},
verify=False,
)
users = response.json()
print(users)
assert users[0]["roles"] == []
user = response.json()
assert user["roles"] == [
"user",
"manage-account",
"jupyterhub_developer",
"argo-developer",
"dask_gateway_developer",
"grafana_viewer",
"conda_store_developer",
"argo-viewer",
"grafana_developer",
"manage-account-links",
"view-profile",
]


@pytest.mark.filterwarnings("ignore::urllib3.exceptions.InsecureRequestWarning")
def test_jupyterhub_loads_groups_from_keycloak():
session = get_jupyterhub_session()
xsrf_token = session.cookies.get("_xsrf")
response = session.get(
f"https://{constants.NEBARI_HOSTNAME}/hub/api/users/{constants.KEYCLOAK_USERNAME}",
headers={"X-XSRFToken": xsrf_token},
verify=False,
)
user = response.json()
assert user["groups"] == ["/analyst", "/developer", "/users"]

0 comments on commit 3fe718c

Please sign in to comment.