From c2ce06fb5e0476c83ed95fc9ba616ec224dad70e Mon Sep 17 00:00:00 2001 From: Andrei Neagu Date: Wed, 3 Jul 2024 10:28:11 +0200 Subject: [PATCH 1/2] fix missing projects entry for dynamic sidecar based services --- .../studies_dispatcher/_redirects_handlers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/web/server/src/simcore_service_webserver/studies_dispatcher/_redirects_handlers.py b/services/web/server/src/simcore_service_webserver/studies_dispatcher/_redirects_handlers.py index 163ca4d754b..00217822f5f 100644 --- a/services/web/server/src/simcore_service_webserver/studies_dispatcher/_redirects_handlers.py +++ b/services/web/server/src/simcore_service_webserver/studies_dispatcher/_redirects_handlers.py @@ -1,6 +1,7 @@ """ Handles request to the viewers redirection entrypoints """ + import functools import logging import urllib.parse @@ -16,6 +17,7 @@ from servicelib.aiohttp.typing_extension import Handler from servicelib.error_codes import create_error_code +from ..director_v2.api import update_dynamic_service_networks_in_project from ..products.api import get_product_name from ..utils import compose_support_error_msg from ..utils_aiohttp import create_redirect_to_page_response @@ -252,6 +254,7 @@ async def get_redirection_to_viewer(request: web.Request): file_params.download_link, product_name=get_product_name(request), ) + await update_dynamic_service_networks_in_project(request.app, project_id) response = _create_redirect_response_to_view_page( request.app, @@ -280,6 +283,7 @@ async def get_redirection_to_viewer(request: web.Request): service_info=_create_service_info_from(valid_service), product_name=get_product_name(request), ) + await update_dynamic_service_networks_in_project(request.app, project_id) response = _create_redirect_response_to_view_page( request.app, @@ -315,6 +319,7 @@ async def get_redirection_to_viewer(request: web.Request): ).STUDIES_DEFAULT_FILE_THUMBNAIL, product_name=get_product_name(request), ) + await update_dynamic_service_networks_in_project(request.app, project_id) response = _create_redirect_response_to_view_page( request.app, From 4a8a190f9c280fb686a04521eb3fa5842ae9c375 Mon Sep 17 00:00:00 2001 From: Andrei Neagu Date: Wed, 3 Jul 2024 12:42:54 +0200 Subject: [PATCH 2/2] expanded test --- .../test_studies_dispatcher_handlers.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/services/web/server/tests/unit/with_dbs/01/studies_dispatcher/test_studies_dispatcher_handlers.py b/services/web/server/tests/unit/with_dbs/01/studies_dispatcher/test_studies_dispatcher_handlers.py index 8157dc8248a..66cb26bbca7 100644 --- a/services/web/server/tests/unit/with_dbs/01/studies_dispatcher/test_studies_dispatcher_handlers.py +++ b/services/web/server/tests/unit/with_dbs/01/studies_dispatcher/test_studies_dispatcher_handlers.py @@ -397,6 +397,10 @@ async def test_dispatch_study_anonymously( "simcore_service_webserver.director_v2.api.create_or_update_pipeline", return_value=None, ) + mock_client_director_v2_project_networks = mocker.patch( + "simcore_service_webserver.studies_dispatcher._redirects_handlers.update_dynamic_service_networks_in_project", + return_value=None, + ) response = await client.get(f"{redirect_url}") @@ -435,6 +439,7 @@ async def test_dispatch_study_anonymously( assert guest_project["prjOwner"] == data["login"] assert mock_client_director_v2_func.called + assert mock_client_director_v2_project_networks.called @pytest.mark.parametrize( @@ -455,10 +460,14 @@ async def test_dispatch_logged_in_user( mocks_on_projects_api, ): assert client.app - mock_client_director_v2_func = mocker.patch( + mock_client_director_v2_pipline_update = mocker.patch( "simcore_service_webserver.director_v2.api.create_or_update_pipeline", return_value=None, ) + mock_client_director_v2_project_networks = mocker.patch( + "simcore_service_webserver.studies_dispatcher._redirects_handlers.update_dynamic_service_networks_in_project", + return_value=None, + ) response = await client.get(f"{redirect_url}") @@ -487,7 +496,8 @@ async def test_dispatch_logged_in_user( assert expected_project_id == created_project["uuid"] assert created_project["prjOwner"] == data["login"] - assert mock_client_director_v2_func.called + assert mock_client_director_v2_pipline_update.called + assert mock_client_director_v2_project_networks.called # delete before exiting url = client.app.router["delete_project"].url_for(project_id=expected_project_id)