Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix broken test.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Sep 29, 2021
1 parent 1bad049 commit da38520
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions synapse/handlers/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
16 changes: 11 additions & 5 deletions tests/handlers/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand Down

0 comments on commit da38520

Please sign in to comment.