diff --git a/src/backend/core/api/serializers.py b/src/backend/core/api/serializers.py index 7e7ef0e0..b8b1f38c 100644 --- a/src/backend/core/api/serializers.py +++ b/src/backend/core/api/serializers.py @@ -32,7 +32,6 @@ class UserSerializer(serializers.ModelSerializer): model = models.User fields = [ "id", - "sub", "email", "full_name", "short_name", @@ -40,7 +39,7 @@ class UserSerializer(serializers.ModelSerializer): "language", "default_encryption_mode", ] - read_only_fields = ["id", "sub", "email", "full_name", "short_name"] + read_only_fields = ["id", "email", "full_name", "short_name"] class UserLightSerializer(serializers.ModelSerializer): diff --git a/src/backend/core/api/viewsets.py b/src/backend/core/api/viewsets.py index 26bcfc13..3bf83deb 100644 --- a/src/backend/core/api/viewsets.py +++ b/src/backend/core/api/viewsets.py @@ -316,7 +316,11 @@ class RoomViewSet( """Start recording a room.""" serializer = serializers.StartRecordingSerializer(data=request.data) - serializer.is_valid(raise_exception=True) + if not serializer.is_valid(): + return drf_response.Response( + {"detail": "Invalid request."}, + status=drf_status.HTTP_400_BAD_REQUEST, + ) mode = serializer.validated_data["mode"] options = serializer.validated_data.get("options") diff --git a/src/backend/core/tests/rooms/test_api_rooms_lobby.py b/src/backend/core/tests/rooms/test_api_rooms_lobby.py index 37ca2124..52b28901 100644 --- a/src/backend/core/tests/rooms/test_api_rooms_lobby.py +++ b/src/backend/core/tests/rooms/test_api_rooms_lobby.py @@ -59,6 +59,7 @@ def test_request_entry_anonymous(settings): "username": "test_user", "status": "waiting", "color": "mocked-color", + "is_authenticated": False, "livekit": None, } @@ -108,6 +109,7 @@ def test_request_entry_authenticated_user(settings): "username": "test_user", "status": "waiting", "color": "mocked-color", + "is_authenticated": True, "livekit": None, } @@ -180,6 +182,7 @@ def test_request_entry_with_existing_participants(settings): "username": "test_user", "status": "waiting", "color": "mocked-color", + "is_authenticated": False, "livekit": None, } @@ -232,6 +235,7 @@ def test_request_entry_public_room(settings): "username": "test_user", "status": "accepted", "color": "mocked-color", + "is_authenticated": False, "livekit": {"token": "test-token"}, } @@ -284,6 +288,7 @@ def test_request_entry_authenticated_user_public_room(settings): "username": "test_user", "status": "accepted", "color": "mocked-color", + "is_authenticated": True, "livekit": {"token": "test-token"}, } @@ -338,6 +343,7 @@ def test_request_entry_waiting_participant_public_room(settings): "username": "user1", "status": "accepted", "color": "#123456", + "is_authenticated": False, "livekit": {"token": "test-token"}, } @@ -601,12 +607,14 @@ def test_list_waiting_participants_success(settings): "username": "user1", "status": "waiting", "color": "#123456", + "is_authenticated": False, }, { "id": "f4ca3ab8a6c04ad88097b8da33f60f10", "username": "user2", "status": "waiting", "color": "#654321", + "is_authenticated": False, }, ] diff --git a/src/backend/core/tests/rooms/test_api_rooms_retrieve.py b/src/backend/core/tests/rooms/test_api_rooms_retrieve.py index f317ddd8..5282a9a9 100644 --- a/src/backend/core/tests/rooms/test_api_rooms_retrieve.py +++ b/src/backend/core/tests/rooms/test_api_rooms_retrieve.py @@ -33,6 +33,7 @@ def test_api_rooms_retrieve_anonymous_private_pk(): "is_administrable": False, "name": room.name, "slug": room.slug, + "encryption_mode": room.encryption_mode, } @@ -52,6 +53,7 @@ def test_api_rooms_retrieve_anonymous_trusted_pk(): "is_administrable": False, "name": room.name, "slug": room.slug, + "encryption_mode": room.encryption_mode, } @@ -70,6 +72,7 @@ def test_api_rooms_retrieve_anonymous_private_pk_no_dashes(): "is_administrable": False, "name": room.name, "slug": room.slug, + "encryption_mode": room.encryption_mode, } @@ -86,6 +89,7 @@ def test_api_rooms_retrieve_anonymous_private_slug(): "is_administrable": False, "name": room.name, "slug": room.slug, + "encryption_mode": room.encryption_mode, } @@ -102,6 +106,7 @@ def test_api_rooms_retrieve_anonymous_private_slug_not_normalized(): "is_administrable": False, "name": room.name, "slug": room.slug, + "encryption_mode": room.encryption_mode, } @@ -211,6 +216,7 @@ def test_api_rooms_retrieve_anonymous_public(mock_token): "name": room.name, "pin_code": room.pin_code, "slug": room.slug, + "encryption_mode": room.encryption_mode, } mock_token.assert_called_once() @@ -257,6 +263,7 @@ def test_api_rooms_retrieve_authenticated_public(mock_token): "name": room.name, "pin_code": room.pin_code, "slug": room.slug, + "encryption_mode": room.encryption_mode, } mock_token.assert_called_once_with( @@ -267,6 +274,7 @@ def test_api_rooms_retrieve_authenticated_public(mock_token): sources=["mock-source"], is_admin_or_owner=False, participant_id=None, + encryption_mode="none", ) @@ -308,6 +316,7 @@ def test_api_rooms_retrieve_authenticated_trusted(mock_token): "name": room.name, "pin_code": room.pin_code, "slug": room.slug, + "encryption_mode": room.encryption_mode, } mock_token.assert_called_once_with( @@ -318,6 +327,7 @@ def test_api_rooms_retrieve_authenticated_trusted(mock_token): sources=None, is_admin_or_owner=False, participant_id=None, + encryption_mode="none", ) @@ -343,6 +353,7 @@ def test_api_rooms_retrieve_authenticated(): "is_administrable": False, "name": room.name, "slug": room.slug, + "encryption_mode": room.encryption_mode, } @@ -394,6 +405,7 @@ def test_api_rooms_retrieve_members(mock_token, django_assert_num_queries, setti "name": room.name, "pin_code": room.pin_code, "slug": room.slug, + "encryption_mode": room.encryption_mode, } mock_token.assert_called_once_with( @@ -404,6 +416,7 @@ def test_api_rooms_retrieve_members(mock_token, django_assert_num_queries, setti sources=["mock-source"], is_admin_or_owner=False, participant_id=None, + encryption_mode="none", ) @@ -453,6 +466,7 @@ def test_api_rooms_retrieve_administrators( "short_name": other_user_access.user.short_name, "timezone": "UTC", "language": other_user_access.user.language, + "default_encryption_mode": "none", }, "resource": str(room.id), "role": other_user_access.role, @@ -466,6 +480,7 @@ def test_api_rooms_retrieve_administrators( "short_name": user_access.user.short_name, "timezone": "UTC", "language": user_access.user.language, + "default_encryption_mode": "none", }, "resource": str(room.id), "role": user_access.role, @@ -487,6 +502,7 @@ def test_api_rooms_retrieve_administrators( "name": room.name, "pin_code": room.pin_code, "slug": room.slug, + "encryption_mode": room.encryption_mode, } mock_token.assert_called_once_with( @@ -497,4 +513,5 @@ def test_api_rooms_retrieve_administrators( sources=None, is_admin_or_owner=True, participant_id=None, + encryption_mode="none", ) diff --git a/src/backend/core/tests/services/test_lobby.py b/src/backend/core/tests/services/test_lobby.py index ce7746c7..c8b25ced 100644 --- a/src/backend/core/tests/services/test_lobby.py +++ b/src/backend/core/tests/services/test_lobby.py @@ -268,6 +268,7 @@ def test_request_entry_public_room( configuration=room.configuration, is_admin_or_owner=False, participant_id="test-participant-id", + encryption_mode="none", ) lobby_service._get_participant.assert_called_once_with(room.id, participant_id) @@ -307,6 +308,7 @@ def test_request_entry_trusted_room( configuration=room.configuration, is_admin_or_owner=False, participant_id="test-participant-id", + encryption_mode="none", ) lobby_service._get_participant.assert_called_once_with(room.id, participant_id) @@ -337,7 +339,12 @@ def test_request_entry_new_participant( assert participant == participant_data assert livekit_config is None - mock_enter.assert_called_once_with(room.id, participant_id, username) + mock_enter.assert_called_once_with( + room.id, + participant_id, + username, + is_authenticated=request.user.is_authenticated, + ) lobby_service._get_participant.assert_called_once_with(room.id, participant_id) @@ -402,6 +409,7 @@ def test_request_entry_accepted_participant( configuration=room.configuration, is_admin_or_owner=False, participant_id="test-participant-id", + encryption_mode="none", ) lobby_service._get_participant.assert_called_once_with(room.id, participant_id) @@ -777,6 +785,7 @@ def test_update_participant_status_success(mock_cache, lobby_service, participan "username": "test-username", "id": participant_id, "color": "#123456", + "is_authenticated": False, } mock_cache.set.assert_called_once_with( "mocked_cache_key", expected_data, timeout=60 diff --git a/src/backend/core/tests/test_api_users.py b/src/backend/core/tests/test_api_users.py index 37fb32b7..72d60302 100644 --- a/src/backend/core/tests/test_api_users.py +++ b/src/backend/core/tests/test_api_users.py @@ -125,6 +125,7 @@ def test_api_users_retrieve_me_authenticated(settings): "short_name": user.short_name, "language": user.language, "timezone": "UTC", + "default_encryption_mode": "none", }