✨(backend) force ProConnect official name in trusted rooms#1155
✨(backend) force ProConnect official name in trusted rooms#1155mmaudet wants to merge 1 commit intosuitenumerique:mainfrom
Conversation
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
WalkthroughThis pull request implements username override logic for authenticated users accessing trusted rooms. The changes add functionality to set the LiveKit token username to the user's official full_name (or string representation as fallback) in trusted room scenarios. Modifications are made to the serializer's Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can enforce grammar and style rules using `languagetool`.Configure the |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/backend/core/tests/services/test_lobby.py (1)
374-409: 🧹 Nitpick | 🔵 TrivialConsider adding a test for the fallback case when
full_nameis empty.The test
test_request_entry_accepted_participantuses a RESTRICTED room, so it doesn't exercise the trusted room code path for already-accepted participants. Additionally, there's no test covering the fallback tostr(user)whenfull_nameis empty in the lobby service (the serializers tests have this coverage but the lobby tests don't).Would you like me to help draft additional test cases for:
- An accepted participant in a trusted room (exercising lines 186-191 in lobby.py)
- The fallback to
str(user)whenfull_nameis empty?🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/backend/core/tests/services/test_lobby.py` around lines 374 - 409, Add tests covering two missing cases: (1) an accepted participant in a trusted room so request_entry follows the trusted-room branch (create a RoomFactory with access_level=RoomAccessLevel.TRUSTED and assert lobby_service.request_entry returns the participant and calls generate_livekit_config with is_admin_or_owner=False and the participant's color/username), and (2) the fallback to str(user) when full_name is empty by mocking request.user.full_name = "" (or ensuring the user object has no full_name) and asserting that generate_livekit_config is called with username equal to str(request.user); use the same patterns as test_request_entry_accepted_participant to mock lobby_service._get_or_create_participant_id, lobby_service._get_participant, and generate_livekit_config and assert calls and returned values.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/backend/core/tests/services/test_lobby.py`:
- Around line 374-409: Add tests covering two missing cases: (1) an accepted
participant in a trusted room so request_entry follows the trusted-room branch
(create a RoomFactory with access_level=RoomAccessLevel.TRUSTED and assert
lobby_service.request_entry returns the participant and calls
generate_livekit_config with is_admin_or_owner=False and the participant's
color/username), and (2) the fallback to str(user) when full_name is empty by
mocking request.user.full_name = "" (or ensuring the user object has no
full_name) and asserting that generate_livekit_config is called with username
equal to str(request.user); use the same patterns as
test_request_entry_accepted_participant to mock
lobby_service._get_or_create_participant_id, lobby_service._get_participant, and
generate_livekit_config and assert calls and returned values.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 7ecd07b4-cded-4d15-9cc9-0ba5dc834807
📒 Files selected for processing (4)
src/backend/core/api/serializers.pysrc/backend/core/services/lobby.pysrc/backend/core/tests/rooms/test_api_rooms_retrieve.pysrc/backend/core/tests/services/test_lobby.py
When a room has trusted access level and the user is authenticated, override the username with the user's full_name from ProConnect claims to prevent identity fraud. Falls back to email if full_name is empty. Closes suitenumerique#784
b73ff99 to
4b84bd9
Compare
|



Summary
full_namefrom the OIDC claimsstr(user)(email) iffull_nameis not availableCloses #784
Test plan
full_nameset → verify fallback to emailpytest src/backend/core/tests/rooms/test_api_rooms_retrieve.py src/backend/core/tests/services/test_lobby.py