summary refs log tree commit diff
diff options
context:
space:
mode:
authorNeil Johnson <neil@matrix.org>2019-03-19 10:38:33 +0000
committerNeil Johnson <neil@matrix.org>2019-03-19 10:38:33 +0000
commit4bacb07a456b1364b519e3a1f01890d5b5060e13 (patch)
treec80f95daca633da442ce06b6e5f0c8e192519995
parentfix test_auto_create_auto_join_where_no_consent (diff)
downloadsynapse-4bacb07a456b1364b519e3a1f01890d5b5060e13.tar.xz
remove redundant code and improve comments
-rw-r--r--4887.bugfix1
-rw-r--r--synapse/handlers/register.py1
-rw-r--r--tests/handlers/test_register.py18
3 files changed, 11 insertions, 9 deletions
diff --git a/4887.bugfix b/4887.bugfix
new file mode 100644

index 0000000000..f7c953aef4 --- /dev/null +++ b/4887.bugfix
@@ -0,0 +1 @@ +fix test_auto_create_auto_join_where_no_consent diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py
index eb81556080..68f73d3793 100644 --- a/synapse/handlers/register.py +++ b/synapse/handlers/register.py
@@ -29,7 +29,6 @@ from synapse.api.errors import ( RegistrationError, SynapseError, ) - from synapse.config.server import is_threepid_reserved from synapse.http.client import CaptchaServerHttpClient from synapse.http.servlet import assert_params_in_dict diff --git a/tests/handlers/test_register.py b/tests/handlers/test_register.py
index 001761f2b1..010e65829e 100644 --- a/tests/handlers/test_register.py +++ b/tests/handlers/test_register.py
@@ -21,7 +21,7 @@ from synapse.api.constants import UserTypes 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 @@ -190,27 +190,29 @@ class RegistrationTestCase(unittest.TestCase): """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 = ( - self.hs.config.block_events_without_consent_error - ) + # (Messing with the internals of event_creation_handler is fragile + # but can't see a better way to do this. One option could be to subclass + # the test with custom config.) + event_creation_handler._block_events_without_consent_error = ("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 + # When:- + # * the user is registered and post consent actions are called 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 + # Then:- + # * 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)