Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/api/views/test_graph.py
Show All 33 Lines | |||||
def test_graph_endpoint_needs_authentication(api_client): | def test_graph_endpoint_needs_authentication(api_client): | ||||
url = reverse("api-1-graph", url_args={"graph_query": "stats"}) | url = reverse("api-1-graph", url_args={"graph_query": "stats"}) | ||||
check_http_get_response(api_client, url, status_code=401) | check_http_get_response(api_client, url, status_code=401) | ||||
def _authenticate_graph_user(api_client, keycloak_oidc): | def _authenticate_graph_user(api_client, keycloak_oidc): | ||||
keycloak_oidc.user_permissions = [API_GRAPH_PERM] | keycloak_oidc.client_permissions = [API_GRAPH_PERM] | ||||
oidc_profile = keycloak_oidc.login() | oidc_profile = keycloak_oidc.login() | ||||
api_client.credentials(HTTP_AUTHORIZATION=f"Bearer {oidc_profile['refresh_token']}") | api_client.credentials(HTTP_AUTHORIZATION=f"Bearer {oidc_profile['refresh_token']}") | ||||
def test_graph_endpoint_needs_permission(api_client, keycloak_oidc, requests_mock): | def test_graph_endpoint_needs_permission(api_client, keycloak_oidc, requests_mock): | ||||
graph_query = "stats" | graph_query = "stats" | ||||
url = reverse("api-1-graph", url_args={"graph_query": graph_query}) | url = reverse("api-1-graph", url_args={"graph_query": graph_query}) | ||||
oidc_profile = keycloak_oidc.login() | oidc_profile = keycloak_oidc.login() | ||||
▲ Show 20 Lines • Show All 211 Lines • Show Last 20 Lines |