-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8da2f9
commit 3fe718c
Showing
1 changed file
with
29 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |