-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix test_auto_create_auto_join_where_no_consent #4886
Changes from 2 commits
0a53820
9ad6816
4bacb07
7480fd3
97bd466
c723813
6e54268
195c2b6
c61bcae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ | |
from synapse.api.errors import ResourceLimitError, SynapseError | ||
from synapse.handlers.register import RegistrationHandler | ||
from synapse.types import RoomAlias, UserID, create_requester | ||
|
||
from synapse.api.urls import ConsentURIBuilder | ||
from tests.utils import setup_test_homeserver | ||
|
||
from .. import unittest | ||
|
@@ -187,12 +187,30 @@ def test_auto_create_auto_join_rooms_when_support_user_exists(self): | |
|
||
@defer.inlineCallbacks | ||
def test_auto_create_auto_join_where_no_consent(self): | ||
"""Test to ensure that the first user is not auto-joined to a room if | ||
they have not given general consent. | ||
""" | ||
self.hs.config.user_consent_at_registration = True | ||
self.hs.config.block_events_without_consent_error = "Error" | ||
|
||
# Given:- | ||
# * a user must give consent, | ||
# * they have not given that consent | ||
# * The server is configured to auto-join to a room | ||
# (and autocreate if necessary) | ||
event_creation_handler = self.hs.get_event_creation_handler() | ||
event_creation_handler._block_events_without_consent_error = ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit dubious about this poking into the guts of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this really mings - I'll comment explicitly to make it clearer |
||
self.hs.config.block_events_without_consent_error | ||
) | ||
event_creation_handler._consent_uri_builder = Mock() | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this doesn't seem to make sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've tried to make it clearer with formatting |
||
res = yield self.handler.register(localpart='jeff') | ||
yield self.handler.post_consent_actions(res[0]) | ||
|
||
# Ensure that they have not been joined to the room | ||
rooms = yield self.store.get_rooms_for_user(res[0]) | ||
self.assertEqual(len(rooms), 0) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this and the next line actually do anything? I'd expect them to be redundant now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope