diff --git a/services/web/server/src/simcore_service_webserver/conversations/_controller/_conversations_messages_rest.py b/services/web/server/src/simcore_service_webserver/conversations/_controller/_conversations_messages_rest.py index 56440e5c24e0..5a774c584dd3 100644 --- a/services/web/server/src/simcore_service_webserver/conversations/_controller/_conversations_messages_rest.py +++ b/services/web/server/src/simcore_service_webserver/conversations/_controller/_conversations_messages_rest.py @@ -117,10 +117,7 @@ async def create_conversation_message(request: web.Request): request, template_name ) _url = request.url - if _url.port: - _conversation_url = f"{_url.scheme}://{_url.host}:{_url.port}/#/conversations/{path_params.conversation_id}" - else: - _conversation_url = f"{_url.scheme}://{_url.host}/#/conversations/{path_params.conversation_id}" + _conversation_url = f"{_url.scheme}://{_url.host}/#/conversation/{path_params.conversation_id}" _extra_context = _conversation.extra_context await email_service.send_email_from_template( request, diff --git a/services/web/server/src/simcore_service_webserver/groups/_groups_repository.py b/services/web/server/src/simcore_service_webserver/groups/_groups_repository.py index 8c04d62b2d33..05bed6c18d68 100644 --- a/services/web/server/src/simcore_service_webserver/groups/_groups_repository.py +++ b/services/web/server/src/simcore_service_webserver/groups/_groups_repository.py @@ -550,12 +550,16 @@ async def list_users_in_group( # Get all users in the group query = ( - sa.select(*_GROUP_COLUMNS) - .select_from( - groups.join( - user_to_groups, user_to_groups.c.gid == groups.c.gid, isouter=True - ).join(users, users.c.id == user_to_groups.c.uid) + sa.select( + users.c.id, + users.c.name, + users.c.email, + users.c.first_name, + users.c.last_name, + users.c.primary_gid, + # user_to_groups.c.access_rights, # <-- currently not neccessary, might be added if needed ) + .select_from(users.join(user_to_groups, users.c.id == user_to_groups.c.uid)) .where(user_to_groups.c.gid == group_id) ) diff --git a/services/web/server/tests/unit/with_dbs/01/groups/test_groups_repository.py b/services/web/server/tests/unit/with_dbs/01/groups/test_groups_repository.py new file mode 100644 index 000000000000..91f1aa485116 --- /dev/null +++ b/services/web/server/tests/unit/with_dbs/01/groups/test_groups_repository.py @@ -0,0 +1,74 @@ +# pylint: disable=redefined-outer-name +# pylint: disable=too-many-arguments +# pylint: disable=unused-argument +# pylint: disable=unused-variable + +from collections.abc import AsyncGenerator, Callable, Coroutine +from typing import Any + +import pytest +from aiohttp.test_utils import TestClient +from models_library.groups import GroupMember, StandardGroupCreate +from pytest_simcore.helpers.webserver_users import UserInfoDict +from simcore_postgres_database.models.users import UserRole +from simcore_service_webserver.groups import _groups_repository + + +@pytest.fixture +async def create_test_group( + client: TestClient, logged_user: UserInfoDict +) -> AsyncGenerator[Callable[..., Coroutine[Any, Any, Any]], None]: + """Fixture that creates a standard group and ensures cleanup.""" + created_groups = [] + + async def _create_group( + name: str = "Test Group", + description: str = "A test group", + thumbnail: str | None = None, + ): + group, _ = await _groups_repository.create_standard_group( + app=client.app, + user_id=logged_user["id"], + create=StandardGroupCreate( + name=name, + description=description, + thumbnail=thumbnail, + ), + ) + created_groups.append(group) + return group + + yield _create_group + + # Cleanup all created groups + for group in created_groups: + await _groups_repository.delete_standard_group( + app=client.app, user_id=logged_user["id"], group_id=group.gid + ) + + +@pytest.mark.parametrize("user_role", [UserRole.USER]) +async def test_list_users_in_group_owner_only( + client: TestClient, + user_role: UserRole, + logged_user: UserInfoDict, + create_test_group: Callable[..., Coroutine[Any, Any, Any]], +): + """Test list_users_in_group returns only the owner for a new group.""" + assert client.app + + # Create a standard group + group = await create_test_group( + name="Test Owner Only Group", + description="A test group to check owner-only user list", + ) + + # List users in the group - should only contain the owner + users_in_group = await _groups_repository.list_users_in_group( + app=client.app, group_id=group.gid + ) + + # Should contain exactly one user (the owner) + assert len(users_in_group) == 1 + assert isinstance(users_in_group[0], GroupMember) + assert users_in_group[0].id == logged_user["id"]