summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2019-03-19 11:43:46 +0000
committerRichard van der Hoff <richard@matrix.org>2019-03-19 11:43:46 +0000
commit45c4e19c74d8b3e05af221ffc5c81e04bd427fcc (patch)
tree6a6e9743f1c6926690c6e070abec0dbc5efc0fa7 /tests
parentEnforce hs_disabled_message correctly (diff)
parentfix test_auto_create_auto_join_where_no_consent (#4886) (diff)
downloadsynapse-45c4e19c74d8b3e05af221ffc5c81e04bd427fcc.tar.xz
Merge remote-tracking branch 'origin/develop' into HEAD
Diffstat (limited to 'tests')
-rw-r--r--tests/handlers/test_register.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/tests/handlers/test_register.py b/tests/handlers/test_register.py
index c9c1506273..010e65829e 100644
--- a/tests/handlers/test_register.py
+++ b/tests/handlers/test_register.py
@@ -187,12 +187,32 @@ class RegistrationTestCase(unittest.TestCase):
 
     @defer.inlineCallbacks
     def test_auto_create_auto_join_where_no_consent(self):
-        self.hs.config.user_consent_at_registration = True
-        self.hs.config.block_events_without_consent_error = "Error"
+        """Test to ensure that the first user is not auto-joined to a room if
+        they have not given general consent.
+        """
+
+        # 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()
+        # (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
         res = yield self.handler.register(localpart='jeff')
         yield self.handler.post_consent_actions(res[0])
+
+        # 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)