From cf3a25e0d7676a7ae3a13536ae3bfe4187102bad Mon Sep 17 00:00:00 2001 From: Arjan Molenaar Date: Mon, 13 Nov 2023 21:50:13 +0100 Subject: [PATCH] fix: refactor session launching --- backend/capellacollab/sessions/routes.py | 9 +++++++-- backend/tests/sessions/test_session_hooks.py | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/capellacollab/sessions/routes.py b/backend/capellacollab/sessions/routes.py index 884ef9658a..b7f889dde3 100644 --- a/backend/capellacollab/sessions/routes.py +++ b/backend/capellacollab/sessions/routes.py @@ -283,7 +283,6 @@ def request_persistent_session( ), db: orm.Session = fastapi.Depends(database.get_db), operator: k8s.KubernetesOperator = fastapi.Depends(operators.get_operator), - username: str = fastapi.Depends(auth_injectables.get_username), ): log.info("Starting persistent session for user %s", user.name) @@ -294,6 +293,12 @@ def request_persistent_session( raise_if_conflicting_persistent_sessions(tool, user) + response = start_persistent_session(user, tool, version, operator, db) + + return response + + +def start_persistent_session(user, tool, version, operator, db): environment: dict[str, str] = {} volumes: list[operators_models.Volume] = [] warnings: list[core_models.Message] = [] @@ -304,7 +309,7 @@ def request_persistent_session( user=user, tool_version=version, tool=tool, - username=username, + username=user.name, operator=operator, ) environment |= hook_env diff --git a/backend/tests/sessions/test_session_hooks.py b/backend/tests/sessions/test_session_hooks.py index 36c1a73dc9..bcc644756b 100644 --- a/backend/tests/sessions/test_session_hooks.py +++ b/backend/tests/sessions/test_session_hooks.py @@ -162,7 +162,6 @@ def test_session_creation_hook_is_called( user, db, mockoperator, - "testuser", ) assert session_hook.configuration_hook_counter == 1