From da3852044d6e814bb5ea65979e8d7ee0cc2da7f8 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 29 Sep 2021 13:52:45 -0400 Subject: [PATCH] Fix broken test. --- synapse/handlers/register.py | 2 ++ tests/handlers/test_register.py | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py index b27f24386b57..cb4eb0720b5e 100644 --- a/synapse/handlers/register.py +++ b/synapse/handlers/register.py @@ -340,6 +340,8 @@ async def register_user( auth_provider=(auth_provider_id or ""), ).inc() + # If the user does not need to consent at registration, auto-join any + # configured rooms. if not self.hs.config.consent.user_consent_at_registration: if not self.hs.config.auto_join_rooms_for_guests and make_guest: logger.info( diff --git a/tests/handlers/test_register.py b/tests/handlers/test_register.py index 74c1263946a4..db691c4c1c30 100644 --- a/tests/handlers/test_register.py +++ b/tests/handlers/test_register.py @@ -521,9 +521,13 @@ def test_auto_create_auto_join_room_preset_invalid_permissions(self): @override_config( { - "user_consent": {"block_events_error": "Error"}, + "user_consent": { + "block_events_error": "Error", + "require_at_registration": True, + }, "form_secret": "53cr3t", "public_baseurl": "http://test", + "auto_join_rooms": ["#room:test"], }, ) def test_auto_create_auto_join_where_no_consent(self): @@ -536,19 +540,21 @@ def test_auto_create_auto_join_where_no_consent(self): # * they have not given that consent # * The server is configured to auto-join to a room # (and autocreate if necessary) - room_alias_str = "#room:test" - self.hs.config.auto_join_rooms = [room_alias_str] # When:- - # * the user is registered and post consent actions are called + # * the user is registered user_id = self.get_success(self.handler.register_user(localpart="jeff")) - self.get_success(self.handler.post_consent_actions(user_id)) # Then:- # * Ensure that they have not been joined to the room rooms = self.get_success(self.store.get_rooms_for_user(user_id)) self.assertEqual(len(rooms), 0) + # The user provides consent; ensure they are now in the rooms. + self.get_success(self.handler.post_consent_actions(user_id)) + rooms = self.get_success(self.store.get_rooms_for_user(user_id)) + self.assertEqual(len(rooms), 1) + def test_register_support_user(self): user_id = self.get_success( self.handler.register_user(localpart="user", user_type=UserTypes.SUPPORT)