summary refs log tree commit diff
path: root/tests/handlers/test_room_summary.py
diff options
context:
space:
mode:
authorKrishan <33421343+kfiven@users.noreply.github.com>2024-08-29 00:45:49 +1000
committerGitHub <noreply@github.com>2024-08-28 15:45:49 +0100
commite75a23a63d5fe8edb0145bdd55b98d9e6a29b2ab (patch)
tree843707f3fa72fd39658b4786619be2dd232a8fb9 /tests/handlers/test_room_summary.py
parentFix content length on federation `/thumbnail` responses (#17532) (diff)
downloadsynapse-e75a23a63d5fe8edb0145bdd55b98d9e6a29b2ab.tar.xz
Fix hierarchy returning 403 when room is accessible through federation (#17194)
Diffstat (limited to '')
-rw-r--r--tests/handlers/test_room_summary.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/handlers/test_room_summary.py b/tests/handlers/test_room_summary.py

index 244a4e7689..b55fa1a8fd 100644 --- a/tests/handlers/test_room_summary.py +++ b/tests/handlers/test_room_summary.py
@@ -757,6 +757,54 @@ class SpaceSummaryTestCase(unittest.HomeserverTestCase): ) self._assert_hierarchy(result, expected) + def test_fed_root(self) -> None: + """ + Test if requested room is available over federation. + """ + fed_hostname = self.hs.hostname + "2" + fed_space = "#fed_space:" + fed_hostname + fed_subroom = "#fed_sub_room:" + fed_hostname + + requested_room_entry = _RoomEntry( + fed_space, + { + "room_id": fed_space, + "world_readable": True, + "room_type": RoomTypes.SPACE, + }, + [ + { + "type": EventTypes.SpaceChild, + "room_id": fed_space, + "state_key": fed_subroom, + "content": {"via": [fed_hostname]}, + } + ], + ) + child_room = { + "room_id": fed_subroom, + "world_readable": True, + } + + async def summarize_remote_room_hierarchy( + _self: Any, room: Any, suggested_only: bool + ) -> Tuple[Optional[_RoomEntry], Dict[str, JsonDict], Set[str]]: + return requested_room_entry, {fed_subroom: child_room}, set() + + expected = [ + (fed_space, [fed_subroom]), + (fed_subroom, ()), + ] + + with mock.patch( + "synapse.handlers.room_summary.RoomSummaryHandler._summarize_remote_room_hierarchy", + new=summarize_remote_room_hierarchy, + ): + result = self.get_success( + self.handler.get_room_hierarchy(create_requester(self.user), fed_space) + ) + self._assert_hierarchy(result, expected) + def test_fed_filtering(self) -> None: """ Rooms returned over federation should be properly filtered to only include