summary refs log tree commit diff
path: root/tests/handlers
diff options
context:
space:
mode:
authorNeil Johnson <neil@matrix.org>2019-03-19 11:38:59 +0000
committerRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2019-03-19 11:38:59 +0000
commit88f0675967d629ed14ae6ea6d4815bd0b5e0a44e (patch)
tree1c7449b3fdb5101d1823c07fb65bdcf54421d6ab /tests/handlers
parentFix user directory background update (#4887) (diff)
downloadsynapse-88f0675967d629ed14ae6ea6d4815bd0b5e0a44e.tar.xz
fix test_auto_create_auto_join_where_no_consent (#4886)
Diffstat (limited to '')
-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)